From 05a513898a9f1949b7e3bb61ea687adaa512238d Mon Sep 17 00:00:00 2001 From: Paramtamtam <7326800+tarampampam@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:59:10 +0400 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Ignore=20URL=20parameters?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/http/handlers/error_page/handler.go | 2 +- internal/http/handlers/error_page/handler_test.go | 2 +- internal/http/server.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/http/handlers/error_page/handler.go b/internal/http/handlers/error_page/handler.go index 74d46ea..0e6de6b 100644 --- a/internal/http/handlers/error_page/handler.go +++ b/internal/http/handlers/error_page/handler.go @@ -22,7 +22,7 @@ func New(cfg *config.Config, log *logger.Logger) fasthttp.RequestHandler { //nol code uint16 ) - if fromUrl, okUrl := extractCodeFromURL(string(ctx.RequestURI())); okUrl { + if fromUrl, okUrl := extractCodeFromURL(string(ctx.Path())); okUrl { code = fromUrl } else if fromHeader, okHeaders := extractCodeFromHeaders(reqHeaders); okHeaders { code = fromHeader diff --git a/internal/http/handlers/error_page/handler_test.go b/internal/http/handlers/error_page/handler_test.go index 2bbbbad..fa1faf3 100644 --- a/internal/http/handlers/error_page/handler_test.go +++ b/internal/http/handlers/error_page/handler_test.go @@ -61,7 +61,7 @@ func TestHandler(t *testing.T) { return &cfg }, - giveUrl: "http://testing/503.html", + giveUrl: "http://testing/503.html?rnd=123", giveHeaders: map[string]string{"Accept": "application/json", "X-FooBar": "baz"}, wantStatusCode: http.StatusServiceUnavailable, diff --git a/internal/http/server.go b/internal/http/server.go index 82b4aa0..7b1df00 100644 --- a/internal/http/server.go +++ b/internal/http/server.go @@ -62,7 +62,7 @@ func (s *Server) Register(cfg *config.Config) error { ) s.server.Handler = func(ctx *fasthttp.RequestCtx) { - var url, method = string(ctx.RequestURI()), string(ctx.Method()) + var url, method = string(ctx.Path()), string(ctx.Method()) switch { // live endpoints