getURLParam() was made into a private module func.

This commit is contained in:
Alexander Andreev 2023-01-08 17:53:13 +04:00
parent ea9877f6c4
commit 6ab62fc43b
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F
2 changed files with 5 additions and 5 deletions

View File

@ -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 {

View File

@ -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)
}