mirror of
https://github.com/ClusterCockpit/cc-backend
synced 2024-11-10 08:57:25 +01:00
Add recovery handler
This commit is contained in:
parent
62e776ef7d
commit
6d0a9ce6e8
@ -482,14 +482,15 @@ func main() {
|
|||||||
|
|
||||||
r.PathPrefix("/").Handler(http.FileServer(http.Dir(programConfig.StaticFiles)))
|
r.PathPrefix("/").Handler(http.FileServer(http.Dir(programConfig.StaticFiles)))
|
||||||
r.Use(handlers.CompressHandler)
|
r.Use(handlers.CompressHandler)
|
||||||
|
r.Use(handlers.RecoveryHandler(handlers.PrintRecoveryStack(true)))
|
||||||
r.Use(handlers.CORS(
|
r.Use(handlers.CORS(
|
||||||
handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}),
|
handlers.AllowedHeaders([]string{"X-Requested-With", "Content-Type", "Authorization"}),
|
||||||
handlers.AllowedMethods([]string{"GET", "POST", "HEAD", "OPTIONS"}),
|
handlers.AllowedMethods([]string{"GET", "POST", "HEAD", "OPTIONS"}),
|
||||||
handlers.AllowedOrigins([]string{"*"})))
|
handlers.AllowedOrigins([]string{"*"})))
|
||||||
handler := handlers.CustomLoggingHandler(log.InfoWriter, r, func(w io.Writer, params handlers.LogFormatterParams) {
|
handler := handlers.CustomLoggingHandler(log.InfoWriter, r, func(w io.Writer, params handlers.LogFormatterParams) {
|
||||||
log.Finfof(w, "%s %s (status: %d, size: %d, duration: %dms)",
|
log.Finfof(w, "%s %s (%d, %.02fkb, %dms)",
|
||||||
params.Request.Method, params.URL.RequestURI(),
|
params.Request.Method, params.URL.RequestURI(),
|
||||||
params.StatusCode, params.Size,
|
params.StatusCode, float32(params.Size)/1024,
|
||||||
time.Since(params.TimeStamp).Milliseconds())
|
time.Since(params.TimeStamp).Milliseconds())
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user