2021-08-25 22:12:19 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
2022-01-24 15:37:43 +01:00
|
|
|
rootCmd.AddCommand(serverCmd)
|
2021-08-25 22:12:19 +02:00
|
|
|
}
|
|
|
|
|
2022-01-24 15:37:43 +01:00
|
|
|
var serverCmd = &cobra.Command{
|
|
|
|
Use: "server",
|
|
|
|
Short: "Run in server mode",
|
|
|
|
Aliases: []string{"service"},
|
2021-08-25 22:12:19 +02:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2021-08-25 22:36:04 +02:00
|
|
|
runService()
|
2021-08-25 22:12:19 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func cropTrailingSlashMiddleware(next http.Handler) http.Handler {
|
|
|
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
|
|
if r.URL.Path != "/" {
|
|
|
|
r.URL.Path = strings.TrimSuffix(r.URL.Path, "/")
|
|
|
|
}
|
|
|
|
next.ServeHTTP(w, r)
|
|
|
|
})
|
|
|
|
}
|