Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
canifa_note
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Hoàng Anh
canifa_note
Commits
784fcbb6
Unverified
Commit
784fcbb6
authored
May 26, 2024
by
Ryo
Committed by
GitHub
May 26, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add panic recovery middleware for grpc and echo server (#3459)
parent
1ccfa81c
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
0 deletions
+27
-0
go.mod
go.mod
+1
-0
go.sum
go.sum
+22
-0
server.go
server/server.go
+4
-0
No files found.
go.mod
View file @
784fcbb6
...
@@ -14,6 +14,7 @@ require (
...
@@ -14,6 +14,7 @@ require (
github.com/google/cel-go v0.20.1
github.com/google/cel-go v0.20.1
github.com/google/uuid v1.6.0
github.com/google/uuid v1.6.0
github.com/gorilla/feeds v1.1.2
github.com/gorilla/feeds v1.1.2
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
github.com/improbable-eng/grpc-web v0.15.0
github.com/improbable-eng/grpc-web v0.15.0
github.com/joho/godotenv v1.5.1
github.com/joho/godotenv v1.5.1
...
...
go.sum
View file @
784fcbb6
This diff is collapsed.
Click to expand it.
server/server.go
View file @
784fcbb6
...
@@ -10,10 +10,12 @@ import (
...
@@ -10,10 +10,12 @@ import (
"github.com/google/uuid"
"github.com/google/uuid"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/pkg/errors"
"github.com/pkg/errors"
"github.com/soheilhy/cmux"
"github.com/soheilhy/cmux"
"google.golang.org/grpc"
"google.golang.org/grpc"
grpc_recovery
"github.com/grpc-ecosystem/go-grpc-middleware/recovery"
storepb
"github.com/usememos/memos/proto/gen/store"
storepb
"github.com/usememos/memos/proto/gen/store"
"github.com/usememos/memos/server/profile"
"github.com/usememos/memos/server/profile"
apiv1
"github.com/usememos/memos/server/router/api/v1"
apiv1
"github.com/usememos/memos/server/router/api/v1"
...
@@ -43,6 +45,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -43,6 +45,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
echoServer
.
Debug
=
true
echoServer
.
Debug
=
true
echoServer
.
HideBanner
=
true
echoServer
.
HideBanner
=
true
echoServer
.
HidePort
=
true
echoServer
.
HidePort
=
true
echoServer
.
Use
(
middleware
.
Recover
())
s
.
echoServer
=
echoServer
s
.
echoServer
=
echoServer
workspaceBasicSetting
,
err
:=
s
.
getOrUpsertWorkspaceBasicSetting
(
ctx
)
workspaceBasicSetting
,
err
:=
s
.
getOrUpsertWorkspaceBasicSetting
(
ctx
)
...
@@ -74,6 +77,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
...
@@ -74,6 +77,7 @@ func NewServer(ctx context.Context, profile *profile.Profile, store *store.Store
grpc
.
MaxRecvMsgSize
(
100
*
1024
*
1024
),
grpc
.
MaxRecvMsgSize
(
100
*
1024
*
1024
),
grpc
.
ChainUnaryInterceptor
(
grpc
.
ChainUnaryInterceptor
(
apiv1
.
NewLoggerInterceptor
()
.
LoggerInterceptor
,
apiv1
.
NewLoggerInterceptor
()
.
LoggerInterceptor
,
grpc_recovery
.
UnaryServerInterceptor
(),
apiv1
.
NewGRPCAuthInterceptor
(
store
,
secret
)
.
AuthenticationInterceptor
,
apiv1
.
NewGRPCAuthInterceptor
(
store
,
secret
)
.
AuthenticationInterceptor
,
))
))
s
.
grpcServer
=
grpcServer
s
.
grpcServer
=
grpcServer
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment