Skip to content

Commit

Permalink
Add the panic recovery middleware to our echoes (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
javorszky committed May 3, 2023
1 parent e5241b0 commit 0e40fe5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions e2core/server/server.go
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/contrib/instrumentation/github.com/labstack/echo/otelecho"
Expand Down Expand Up @@ -58,6 +59,7 @@ func New(l zerolog.Logger, sync *syncer.Syncer, opts *options.Options) (*Server,
e.Use(
mid.UUIDRequestID(),
otelecho.Middleware("e2core"),
middleware.Recover(),
)

d := newDispatcher(ll, b.Connect())
Expand Down
2 changes: 2 additions & 0 deletions e2core/sourceserver/bundle.go
Expand Up @@ -5,6 +5,7 @@ import (
"os"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"github.com/rs/zerolog"

Expand All @@ -30,6 +31,7 @@ func FromBundle(bundlePath string) (*echo.Echo, error) {
e.Use(
mid.UUIDRequestID(),
mid.Logger(l, nil),
middleware.Recover(),
)

rt := NewRouter(l, bs)
Expand Down
4 changes: 4 additions & 0 deletions sat/sat/sat.go
Expand Up @@ -9,6 +9,7 @@ import (
"time"

"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"github.com/rs/zerolog"
"go.opentelemetry.io/otel/trace"
Expand Down Expand Up @@ -73,6 +74,9 @@ func New(config *Config, logger zerolog.Logger, traceProvider trace.TracerProvid
}

sat.server = echo.New()
sat.server.Use(
middleware.Recover(),
)
sat.server.HTTPErrorHandler = kitError.Handler(logger)
sat.server.HideBanner = true

Expand Down

0 comments on commit 0e40fe5

Please sign in to comment.