Include secure middleware.
This commit is contained in:
parent
26e456eae3
commit
959eeda35f
2 changed files with 5 additions and 4 deletions
|
|
@ -31,8 +31,9 @@ func BuildRouter(c *container.Container) {
|
||||||
echomw.RemoveTrailingSlashWithConfig(echomw.TrailingSlashConfig{
|
echomw.RemoveTrailingSlashWithConfig(echomw.TrailingSlashConfig{
|
||||||
RedirectCode: http.StatusMovedPermanently,
|
RedirectCode: http.StatusMovedPermanently,
|
||||||
}),
|
}),
|
||||||
echomw.RequestID(),
|
|
||||||
echomw.Recover(),
|
echomw.Recover(),
|
||||||
|
echomw.Secure(),
|
||||||
|
echomw.RequestID(),
|
||||||
echomw.Gzip(),
|
echomw.Gzip(),
|
||||||
echomw.Logger(),
|
echomw.Logger(),
|
||||||
middleware.LogRequestID(),
|
middleware.LogRequestID(),
|
||||||
|
|
|
||||||
|
|
@ -10,9 +10,9 @@ import (
|
||||||
func LogRequestID() echo.MiddlewareFunc {
|
func LogRequestID() echo.MiddlewareFunc {
|
||||||
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
return func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
rid := c.Response().Header().Get(echo.HeaderXRequestID)
|
rID := c.Response().Header().Get(echo.HeaderXRequestID)
|
||||||
format := fmt.Sprintf(`{"time":"${time_rfc3339_nano}","id":"%s","level":"${level}","prefix":"${prefix}","file":"${short_file}","line":"${line}"}`, rid)
|
format := `{"time":"${time_rfc3339_nano}","id":"%s","level":"${level}","prefix":"${prefix}","file":"${short_file}","line":"${line}"}`
|
||||||
c.Logger().SetHeader(format)
|
c.Logger().SetHeader(fmt.Sprintf(format, rID))
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue