diff --git a/pkg/app/admin.go b/pkg/app/admin.go index 3dd2a92..ca1eaf8 100644 --- a/pkg/app/admin.go +++ b/pkg/app/admin.go @@ -25,11 +25,11 @@ func newAdminHandler() *adminHandler { } } -func (h *adminHandler) Handle(user *auth.User, company *auth.Company, conn *database.Conn, requestPath string) http.Handler { +func (h *adminHandler) Handle(user *auth.User, company *auth.Company, conn *database.Conn) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if !user.LoggedIn { w.WriteHeader(http.StatusUnauthorized) - serveLoginForm(w, r, user, company, requestPath) + serveLoginForm(w, r, user, company, r.RequestURI) return } diff --git a/pkg/app/app.go b/pkg/app/app.go index 8930d8c..a26bb60 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -52,14 +52,13 @@ func New(db *database.DB, avatarsDir string) (http.Handler, error) { } func (h *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { - requestPath := r.URL.Path var head string head, r.URL.Path = httplib.ShiftPath(r.URL.Path) switch head { case "static": h.fileHandler.ServeHTTP(w, r) case "favicon.ico": - r.URL.Path = requestPath + r.URL.Path = head h.fileHandler.ServeHTTP(w, r) default: conn, err := h.db.Acquire(r.Context()) @@ -85,7 +84,7 @@ func (h *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { case "": http.Redirect(w, r, "/"+user.Locale.Language.String()+"/", http.StatusFound) case "admin": - h.admin.Handle(user, company, conn, requestPath).ServeHTTP(w, r) + h.admin.Handle(user, company, conn).ServeHTTP(w, r) case "login": switch r.Method { case http.MethodGet: @@ -100,7 +99,7 @@ func (h *App) ServeHTTP(w http.ResponseWriter, r *http.Request) { httplib.MethodNotAllowed(w, r, http.MethodPost, http.MethodGet) } case "me": - h.profile.Handler(user, company, conn, requestPath).ServeHTTP(w, r) + h.profile.Handler(user, company, conn).ServeHTTP(w, r) default: langTag, err := language.Parse(head) if err != nil { diff --git a/pkg/app/user.go b/pkg/app/user.go index dce876a..c903706 100644 --- a/pkg/app/user.go +++ b/pkg/app/user.go @@ -80,11 +80,11 @@ func newProfileHandler(static http.Handler, avatarsDir string) (*profileHandler, return handler, nil } -func (h *profileHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn, requestPath string) http.HandlerFunc { +func (h *profileHandler) Handler(user *auth.User, company *auth.Company, conn *database.Conn) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { if !user.LoggedIn { w.WriteHeader(http.StatusUnauthorized) - serveLoginForm(w, r, user, company, requestPath) + serveLoginForm(w, r, user, company, r.RequestURI) return }