Skip to content
Snippets Groups Projects
Commit c2e0f43c authored by ale's avatar ale
Browse files

We no longer need a gorilla/mux in the main app

Session handling no longer depends on gorilla/sessions.
parent 1418640d
No related branches found
No related tags found
1 merge request!6Refactor the login handler
Pipeline #5380 passed
...@@ -17,7 +17,6 @@ import ( ...@@ -17,7 +17,6 @@ import (
assetfs "github.com/elazarl/go-bindata-assetfs" assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/gorilla/csrf" "github.com/gorilla/csrf"
"github.com/gorilla/mux"
"github.com/rs/cors" "github.com/rs/cors"
"git.autistici.org/id/auth" "git.autistici.org/id/auth"
...@@ -99,14 +98,11 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi ...@@ -99,14 +98,11 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
return nil, err return nil, err
} }
// The root HTTP handler. This must be a gorilla/mux.Router since // The root HTTP handler. If a URL prefix is set, we can't
// session handling depends on it. // just add a StripPrefix in front of everything, as the
// // handlers need access to the actual full request URL, so we
// If a URL prefix is set, we can't just add a StripPrefix in // just inject the prefix everywhere.
// front of everything, as the handlers need access to the root := http.NewServeMux()
// actual full request URL, so we just inject the prefix
// everywhere.
root := mux.NewRouter()
// If we have customized content, serve it from well-known URLs. // If we have customized content, serve it from well-known URLs.
if config.SiteLogo != "" { if config.SiteLogo != "" {
...@@ -133,7 +129,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi ...@@ -133,7 +129,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
// Serve static content to anyone. // Serve static content to anyone.
staticPath := h.urlFor("/static/") staticPath := h.urlFor("/static/")
root.PathPrefix(staticPath).Handler(http.StripPrefix(staticPath, http.FileServer(&assetfs.AssetFS{ root.Handle(staticPath, http.StripPrefix(staticPath, http.FileServer(&assetfs.AssetFS{
Asset: Asset, Asset: Asset,
AssetDir: AssetDir, AssetDir: AssetDir,
AssetInfo: AssetInfo, AssetInfo: AssetInfo,
...@@ -171,7 +167,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi ...@@ -171,7 +167,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
}) })
apph = corsp.Handler(apph) apph = corsp.Handler(apph)
root.PathPrefix(h.urlFor("/")).Handler(apph) root.Handle(h.urlFor("/"), apph)
h.handler = root h.handler = root
return h, nil return h, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment