From 170b65bf15bcf52cf2421de30d4587ef8e36da26 Mon Sep 17 00:00:00 2001 From: Lajos Koszti Date: Thu, 1 Oct 2020 13:44:13 +0200 Subject: [PATCH] Fix listener path Make sure api root always has the "/" on the end of the path --- main.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 6eea93a..bcae3cf 100644 --- a/main.go +++ b/main.go @@ -7,6 +7,7 @@ import ( "net/http" "net/url" "path" + "strings" "time" "github.com/Ajnasz/sekret.link/storage" @@ -89,7 +90,13 @@ func main() { apiRoot = webExternalURL.Path } - apiRoot = path.Clean(apiRoot + "/") + apiRoot = path.Clean(apiRoot) + + if !strings.HasSuffix(apiRoot, "/") { + apiRoot += "/" + } + + log.Println("Handle Path: ", apiRoot) http.Handle(apiRoot, http.StripPrefix(apiRoot, secretHandler{}))