worker: Use Recover middleware to handle panics
recover from panics such as out-of-bounds array access & nil pointer access, print a stack trace and return 5xx error
This commit is contained in:
parent
22f151df68
commit
12ca5325d6
1 changed files with 2 additions and 0 deletions
|
|
@ -16,6 +16,7 @@ import (
|
|||
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/osbuild/osbuild-composer/internal/common"
|
||||
|
|
@ -57,6 +58,7 @@ func (s *Server) Handler() http.Handler {
|
|||
|
||||
// log errors returned from handlers
|
||||
e.HTTPErrorHandler = api.HTTPErrorHandler
|
||||
e.Use(middleware.Recover())
|
||||
e.Pre(common.OperationIDMiddleware)
|
||||
handler := apiHandlers{
|
||||
server: s,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue