refactor: use 'c' alias for constants package

- Update all imports from 'constants' to 'c' for brevity
- Replace all 'constants.' references with 'c.'
- Fix remaining hardcoded content-type headers in httputil
- Fix remaining hardcoded User-Agent and Accept headers
- Rename CSRF receiver from 'c' to 'csrf' to avoid conflict
- Add ContentTypePlainSimple constant for Accept header matching
- Fix JSONCached to use proper integer formatting
This commit is contained in:
juanatsap
2025-12-06 16:31:42 +00:00
parent 2c7f8de242
commit 30ed21ff7a
21 changed files with 1335 additions and 167 deletions
+5 -5
View File
@@ -4,15 +4,15 @@ package httputil
import (
"net/http"
"github.com/juanatsap/cv-site/internal/constants"
c "github.com/juanatsap/cv-site/internal/constants"
)
// Lang extracts and validates the language from query params.
// Returns the language or default if invalid/missing.
func Lang(r *http.Request) string {
lang := r.URL.Query().Get("lang")
if lang == "" || !constants.SupportedLanguages[lang] {
return constants.LangDefault
if lang == "" || !c.SupportedLanguages[lang] {
return c.LangDefault
}
return lang
}
@@ -22,9 +22,9 @@ func Lang(r *http.Request) string {
func LangOrError(r *http.Request) (string, bool) {
lang := r.URL.Query().Get("lang")
if lang == "" {
return constants.LangDefault, true
return c.LangDefault, true
}
if !constants.SupportedLanguages[lang] {
if !c.SupportedLanguages[lang] {
return "", false
}
return lang, true