cloudapi: 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
instead of the service crashing and relying on Execution
framework to handle crashes
This commit is contained in:
Diaa Sami 2021-09-23 18:18:54 +02:00 committed by Tom Gundersen
parent bc9e340ca5
commit 60e403e53e
34 changed files with 4304 additions and 0 deletions

View file

@ -15,6 +15,7 @@ import (
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/osbuild/osbuild-composer/internal/blueprint"
"github.com/osbuild/osbuild-composer/internal/common"
@ -58,6 +59,8 @@ func (server *Server) Handler(path string) http.Handler {
e.StdLogger = server.logger
e.Pre(common.OperationIDMiddleware)
e.Use(middleware.Recover())
handler := apiHandlers{
server: server,
}