ekko: add gzip, move recover middleware to run early
This commit is contained in:
18
ekko/ekko.go
18
ekko/ekko.go
@@ -89,6 +89,14 @@ func (ek *Ekko) setup(ctx context.Context) (*echo.Echo, error) {
|
||||
e.Use(ek.otelmiddleware)
|
||||
}
|
||||
|
||||
e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{
|
||||
LogErrorFunc: func(c echo.Context, err error, stack []byte) error {
|
||||
log.ErrorContext(c.Request().Context(), err.Error(), "stack", string(stack))
|
||||
fmt.Println(string(stack))
|
||||
return err
|
||||
},
|
||||
}))
|
||||
|
||||
e.Use(slogecho.NewWithConfig(log,
|
||||
slogecho.Config{
|
||||
WithTraceID: false, // done by logger already
|
||||
@@ -102,6 +110,8 @@ func (ek *Ekko) setup(ctx context.Context) (*echo.Echo, error) {
|
||||
}))
|
||||
}
|
||||
|
||||
e.Use(middleware.Gzip())
|
||||
|
||||
e.Use(middleware.Secure())
|
||||
|
||||
e.Use(
|
||||
@@ -133,14 +143,6 @@ func (ek *Ekko) setup(ctx context.Context) (*echo.Echo, error) {
|
||||
}
|
||||
})
|
||||
|
||||
// todo: do we want this?
|
||||
e.Use(middleware.RecoverWithConfig(middleware.RecoverConfig{
|
||||
LogErrorFunc: func(c echo.Context, err error, stack []byte) error {
|
||||
log.ErrorContext(c.Request().Context(), err.Error(), "stack", string(stack))
|
||||
return err
|
||||
},
|
||||
}))
|
||||
|
||||
if ek.routeFn != nil {
|
||||
err := ek.routeFn(e)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user