Skip to content

Commit

Permalink
Merge pull request #941 from uber/redirect-hook
Browse files Browse the repository at this point in the history
Add endpointName in redirect function arguments
  • Loading branch information
aharshit29 authored Oct 9, 2024
2 parents ae69a0b + a983f27 commit 1f86ac2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions runtime/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (

type EventHandlerFn func([]Event) error
type EnableEventGenFn func(string, string) bool
type RedirectFn func(w http.ResponseWriter, r *http.Request) bool
type RedirectFn func(w http.ResponseWriter, r *http.Request, endpointGroup, endpointID string) bool

type Event interface {
Name() string
Expand Down Expand Up @@ -131,6 +131,6 @@ func NoOpEventGen(_, _ string) bool {
return false
}

func NoOpRedirectFn(_ http.ResponseWriter, _ *http.Request) bool {
func NoOpRedirectFn(_ http.ResponseWriter, _ *http.Request, _, _ string) bool {
return false
}
2 changes: 1 addition & 1 deletion runtime/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ func TestGatewayWithRedirectHandler(t *testing.T) {
})

t.Run("with redirect handler", func(t *testing.T) {
redirectFn := func(_ http.ResponseWriter, _ *http.Request) bool {
redirectFn := func(_ http.ResponseWriter, _ *http.Request, _, _ string) bool {
return false
}
opts.RedirectProvider = func(gateway *Gateway) RedirectFn {
Expand Down
2 changes: 1 addition & 1 deletion runtime/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (endpoint *RouterEndpoint) HandleRequest(
// defer cancel()
//}

if isRedirected := endpoint.redirectFn(w, r); isRedirected {
if isRedirected := endpoint.redirectFn(w, r, endpoint.EndpointName, endpoint.HandlerName); isRedirected {
return
}

Expand Down

0 comments on commit 1f86ac2

Please sign in to comment.