Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
fix: 미들웨어가 의도되지 않은 시점에서 실행되는 부분 해결
Browse files Browse the repository at this point in the history
  • Loading branch information
2rebi committed Jul 5, 2022
1 parent ea05df0 commit 63a4dab
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion router_lambda.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ func (lr *lambdaRouter) AddRoute(method string, path string, handler HandlerFunc

method = replaceMethodWildcardToBlank(method)
r.params.setParamsInfo(method, findParamKeys(path))
r.handlers.setHandler(method, wrapMiddleware(handler, middleware...))
r.handlers.setHandler(method, func(c Context) error {
wrappedHandler := wrapMiddleware(handler, middleware...)
return wrappedHandler(c)
})
}

func (lr *lambdaRouter) DelRoute(method string, path string) {
Expand Down
5 changes: 4 additions & 1 deletion router_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ func (lr *localRouter) AddRoute(method string, path string, handler HandlerFunc,

method = replaceMethodWildcardToBlank(method)
(*targetRoute).params.setParamsInfo(method, pathParams)
(*targetRoute).handlers.setHandler(method, wrapMiddleware(handler, middleware...))
(*targetRoute).handlers.setHandler(method, func(c Context) error {
wrappedHandler := wrapMiddleware(handler, middleware...)
return wrappedHandler(c)
})
}

func (lr *localRouter) DelRoute(method string, path string) {
Expand Down

0 comments on commit 63a4dab

Please sign in to comment.