aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/router.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/handler/router.go')
-rw-r--r--pkg/handler/router.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/pkg/handler/router.go b/pkg/handler/router.go
index 32bd78a..ee4081b 100644
--- a/pkg/handler/router.go
+++ b/pkg/handler/router.go
@@ -17,12 +17,13 @@ import (
// its sub package don't leak in other places.
func MountHandler(
gitService *service.GitService,
+ authService *service.AuthService,
configRepo *serverconfig.ConfigurationRepository,
) (http.Handler, error) {
var (
gitHandler = git.NewGitHandler(gitService, configRepo)
aboutHandler = about.NewAboutHandler(configRepo)
- loginHandler = &auth.LoginHandler{}
+ loginHandler = auth.NewLoginHandler(authService)
)
staticHandler, err := static.ServeStaticHandler()
@@ -32,10 +33,12 @@ func MountHandler(
mux := ext.NewRouter()
mux.AddMiddleware(ext.Compress)
+ mux.AddMiddleware(ext.Authenticate(authService))
mux.AddMiddleware(ext.Log)
mux.HandleFunc("/static/{file}", staticHandler)
mux.HandleFunc("/login/{$}", loginHandler.Login)
+ mux.HandleFunc("/logout/{$}", loginHandler.Logout)
mux.HandleFunc("/{name}/about/{$}", gitHandler.About)
mux.HandleFunc("/{name}/", gitHandler.Summary)
mux.HandleFunc("/{name}/refs/{$}", gitHandler.Refs)