mirror of
https://github.com/usememos/memos.git
synced 2025-06-05 22:09:59 +02:00
feat: add panic recovery middleware for grpc and echo server (#3459)
This commit is contained in:
@ -10,10 +10,12 @@ import (
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/labstack/echo/v4"
|
||||
"github.com/labstack/echo/v4/middleware"
|
||||
"github.com/pkg/errors"
|
||||
"github.com/soheilhy/cmux"
|
||||
"google.golang.org/grpc"
|
||||
|
||||
grpc_recovery "github.com/grpc-ecosystem/go-grpc-middleware/recovery"
|
||||
storepb "github.com/usememos/memos/proto/gen/store"
|
||||
"github.com/usememos/memos/server/profile"
|
||||
apiv1 "github.com/usememos/memos/server/router/api/v1"
|
||||
@ -43,6 +45,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||
echoServer.Debug = true
|
||||
echoServer.HideBanner = true
|
||||
echoServer.HidePort = true
|
||||
echoServer.Use(middleware.Recover())
|
||||
s.echoServer = echoServer
|
||||
|
||||
workspaceBasicSetting, err := s.getOrUpsertWorkspaceBasicSetting(ctx)
|
||||
@ -74,6 +77,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
|
||||
grpc.MaxRecvMsgSize(100*1024*1024),
|
||||
grpc.ChainUnaryInterceptor(
|
||||
apiv1.NewLoggerInterceptor().LoggerInterceptor,
|
||||
grpc_recovery.UnaryServerInterceptor(),
|
||||
apiv1.NewGRPCAuthInterceptor(store, secret).AuthenticationInterceptor,
|
||||
))
|
||||
s.grpcServer = grpcServer
|
||||
|
Reference in New Issue
Block a user