From 1d525eb7cf73b4200d53d773e77c8acd869fd0c1 Mon Sep 17 00:00:00 2001 From: mountain Date: Sat, 10 Jun 2023 16:27:46 +0900 Subject: [PATCH] =?UTF-8?q?handler=20=EA=B2=BD=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/http_handler.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/server/http_handler.go b/server/http_handler.go index 0226483..f94a260 100644 --- a/server/http_handler.go +++ b/server/http_handler.go @@ -44,15 +44,18 @@ func NewHoustonHandler() HoustonServerWithHandler { func (h *houstonHandler) RegisterHandlers(serveMux *http.ServeMux, prefix string) error { logger.Println("houstonHandler registed") - serveMux.Handle("/"+path.Join(prefix, "houston"), h) + if len(prefix) > 0 { + prefix = "/" + prefix + } + serveMux.Handle(prefix, h) fsx := http.FileServer(http.Dir("deploys")) - serveMux.Handle(fmt.Sprintf("/%s/deploys/", prefix), http.StripPrefix(fmt.Sprintf("/%s/deploys/", prefix), fsx)) + serveMux.Handle(fmt.Sprintf("%s/deploys/", prefix), http.StripPrefix(fmt.Sprintf("%s/deploys/", prefix), fsx)) ufsx := http.FileServer(http.Dir("downloads")) - serveMux.Handle(fmt.Sprintf("/%s/houston/downloads/", prefix), http.StripPrefix(fmt.Sprintf("/%s/houston/downloads/", prefix), ufsx)) + serveMux.Handle(fmt.Sprintf("%s/downloads/", prefix), http.StripPrefix(fmt.Sprintf("%s/downloads/", prefix), ufsx)) - serveMux.HandleFunc("/"+path.Join(prefix, "upload"), func(w http.ResponseWriter, r *http.Request) { + serveMux.HandleFunc(fmt.Sprintf("%s/upload", prefix), func(w http.ResponseWriter, r *http.Request) { defer func() { s := recover() if s != nil {