Skip to content
Snippets Groups Projects

Refactor the login handler

Merged ale requested to merge better-login into master
1 file
+ 7
11
Compare changes
  • Side-by-side
  • Inline
+ 7
11
@@ -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
Loading