Add secure middleware, with sensible values
This commit is contained in:
+1
-8
@@ -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))
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user