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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user