From 6ab62fc43bf2d2dfc906ff379742fb5f6b379767 Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 8 Jan 2023 17:53:13 +0400 Subject: [PATCH] getURLParam() was made into a private module func. --- internal/http/handlers.go | 6 +++--- internal/http/server.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/http/handlers.go b/internal/http/handlers.go index b77bf89..91fe134 100644 --- a/internal/http/handlers.go +++ b/internal/http/handlers.go @@ -30,7 +30,7 @@ func (h *CaptchaHandlers) New(w http.ResponseWriter, r *http.Request) { } func (h *CaptchaHandlers) Image(w http.ResponseWriter, r *http.Request) { - captchaID := captcha.ID(GetURLParam(r, "captcha")) + captchaID := captcha.ID(getURLParam(r, "captcha")) captchaStyle := r.URL.Query().Get("style") captchaImage := inmemdb.Image(captchaID, captchaStyle) @@ -45,7 +45,7 @@ func (h *CaptchaHandlers) Image(w http.ResponseWriter, r *http.Request) { } func (h *CaptchaHandlers) Solve(w http.ResponseWriter, r *http.Request) { - captchaID := captcha.ID(GetURLParam(r, "captcha")) + captchaID := captcha.ID(getURLParam(r, "captcha")) r.ParseForm() answer := captcha.Answer(r.FormValue("answer")) @@ -59,7 +59,7 @@ func (h *CaptchaHandlers) Solve(w http.ResponseWriter, r *http.Request) { } func (h *CaptchaHandlers) IsSolved(w http.ResponseWriter, r *http.Request) { - captchaID := captcha.ID(GetURLParam(r, "captcha")) + captchaID := captcha.ID(getURLParam(r, "captcha")) isJustRemove := r.URL.Query().Has("remove") if isJustRemove { diff --git a/internal/http/server.go b/internal/http/server.go index bac4ca8..8f6426e 100644 --- a/internal/http/server.go +++ b/internal/http/server.go @@ -40,8 +40,8 @@ func (s *HttpServer) SetNotFoundHandler(handler http.HandlerFunc) { s.router.NotFound = handler } -// GetURLParam wrapper around underlying router for getting URL parameters. -func GetURLParam(r *http.Request, param string) string { +// getURLParam wrapper around underlying router for getting URL parameters. +func getURLParam(r *http.Request, param string) string { return httprouter.ParamsFromContext(r.Context()).ByName(param) }