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
This commit is part of merge request !6. Comments created here will be created in the context of that merge request.
......@@ -17,7 +17,6 @@ import (
assetfs "github.com/elazarl/go-bindata-assetfs"
"github.com/gorilla/csrf"
"github.com/gorilla/mux"
"github.com/rs/cors"
"git.autistici.org/id/auth"
......@@ -99,14 +98,11 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
return nil, err
}
// The root HTTP handler. This must be a gorilla/mux.Router since
// session handling depends on it.
//
// If a URL prefix is set, we can't just add a StripPrefix in
// front of everything, as the handlers need access to the
// actual full request URL, so we just inject the prefix
// everywhere.
root := mux.NewRouter()
// The root HTTP handler. If a URL prefix is set, we can't
// just add a StripPrefix in front of everything, as the
// handlers need access to the actual full request URL, so we
// just inject the prefix everywhere.
root := http.NewServeMux()
// If we have customized content, serve it from well-known URLs.
if config.SiteLogo != "" {
......@@ -133,7 +129,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
// Serve static content to anyone.
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,
AssetDir: AssetDir,
AssetInfo: AssetInfo,
......@@ -171,7 +167,7 @@ func New(loginService *LoginService, authClient authclient.Client, config *Confi
})
apph = corsp.Handler(apph)
root.PathPrefix(h.urlFor("/")).Handler(apph)
root.Handle(h.urlFor("/"), apph)
h.handler = root
return h, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment