mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-25 19:39:46 +01:00
Add secure middleware, with sensible values
This commit is contained in:
parent
78c40ab6b4
commit
cd171c40cb
4 changed files with 25 additions and 8 deletions
|
|
@ -53,6 +53,7 @@ func (a *Server) Run(addr string) {
|
|||
func (a *Server) initRoutes() {
|
||||
r := chi.NewRouter()
|
||||
|
||||
r.Use(secureMiddleware())
|
||||
r.Use(cors.AllowAll().Handler)
|
||||
r.Use(middleware.RequestID)
|
||||
r.Use(middleware.RealIP)
|
||||
|
|
@ -88,11 +89,3 @@ func (a *Server) initScanner() {
|
|||
}
|
||||
}()
|
||||
}
|
||||
|
||||
func injectLogger(next http.Handler) http.Handler {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
ctx = log.NewContext(r.Context(), "requestId", ctx.Value(middleware.RequestIDKey))
|
||||
next.ServeHTTP(w, r.WithContext(ctx))
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue