mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
cleanup
This commit is contained in:
parent
47597b2b7c
commit
0b1c90718d
@ -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 != ""
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user