From 0b1c90718d753b7b737712494562080efea9af7e Mon Sep 17 00:00:00 2001 From: Nazar Kanaev Date: Wed, 17 Mar 2021 16:32:13 +0000 Subject: [PATCH] cleanup --- src/server/server.go | 42 ------------------------------------------ 1 file changed, 42 deletions(-) diff --git a/src/server/server.go b/src/server/server.go index 809e8f5..b806088 100644 --- a/src/server/server.go +++ b/src/server/server.go @@ -53,45 +53,3 @@ func (s *Server) Start() { log.Fatal(err) } } - - -/* -func (h Server) ServeHTTP(rw http.ResponseWriter, req *http.Request) { - reqPath := req.URL.Path - if BasePath != "" { - if !strings.HasPrefix(reqPath, BasePath) { - rw.WriteHeader(http.StatusNotFound) - return - } - reqPath = strings.TrimPrefix(req.URL.Path, BasePath) - if reqPath == "" { - http.Redirect(rw, req, BasePath+"/", http.StatusFound) - return - } - } - route, vars := getRoute(reqPath) - if route == nil { - rw.WriteHeader(http.StatusNotFound) - return - } - - if h.requiresAuth() && !route.manualAuth { - if unsafeMethod(req.Method) && req.Header.Get("X-Requested-By") != "yarr" { - rw.WriteHeader(http.StatusUnauthorized) - return - } - if !userIsAuthenticated(req, h.Username, h.Password) { - rw.WriteHeader(http.StatusUnauthorized) - return - } - } - - ctx := context.WithValue(req.Context(), ctxHandler, &h) - ctx = context.WithValue(ctx, ctxVars, vars) - route.handler(rw, req.WithContext(ctx)) -} -*/ - -func (h Server) requiresAuth() bool { - return h.Username != "" && h.Password != "" -}