From a983f2700ea7378f0e8edb8ae0e988c5b4666af2 Mon Sep 17 00:00:00 2001 From: Harshit Agrawal Date: Wed, 9 Oct 2024 17:19:07 +0530 Subject: [PATCH] add endpointName in redirect function arguments --- runtime/events.go | 4 ++-- runtime/gateway_test.go | 2 +- runtime/router.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/runtime/events.go b/runtime/events.go index 6c9b41e7f..55a882aad 100644 --- a/runtime/events.go +++ b/runtime/events.go @@ -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 @@ -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 } diff --git a/runtime/gateway_test.go b/runtime/gateway_test.go index db5d61a5c..fdc6b289e 100644 --- a/runtime/gateway_test.go +++ b/runtime/gateway_test.go @@ -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 { diff --git a/runtime/router.go b/runtime/router.go index dbd4eeb9e..24361f635 100644 --- a/runtime/router.go +++ b/runtime/router.go @@ -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 }