1package web
2
3import (
4 "context"
5 "net/http"
6
7 "github.com/gorilla/handlers"
8 "github.com/gorilla/mux"
9)
10
11// NewRouter returns a new HTTP router.
12func NewRouter(ctx context.Context) http.Handler {
13 router := mux.NewRouter()
14
15 // Git routes
16 GitController(ctx, router)
17
18 router.PathPrefix("/").HandlerFunc(renderNotFound)
19
20 // Context handler
21 // Adds context to the request
22 h := NewContextHandler(ctx)(router)
23 h = handlers.CompressHandler(h)
24 h = handlers.RecoveryHandler()(h)
25 h = NewLoggingMiddleware(h)
26
27 return h
28}