Files
website/internal/handlers/template/error.go
H3ALY ac1f6e9399 refactor(template): delegate handler-level RenderError to helpers package
- Moved core RenderError logic to internal/helpers/template/error.go
- Added thin wrapper method in internal/handlers/template/error.go
- Simplified function signature (no config args, uses InitSiteMeta)
- Preserved architecture: handlers own HTTP layer, helpers supply logic
2025-10-24 13:15:12 +01:00

26 lines
1.1 KiB
Go

package handlers
// ToDo not nessisarily an issue with this file but ✅ internal/handlers/template/
//→ For anything that handles HTTP rendering (RenderError, RenderPage)
//✅ internal/helpers/template/
//→ For anything that helps render (TemplateContext, pagination, funcs)
// there for bear usages between helpers and handlers
//In clean Go architecture (especially following “Package by responsibility”):
//Type Responsibility Should access
//Helpers / Utilities Pure, stateless logic — e.g. template functions, math, formatters. Shared logic, no config, no HTTP handlers.
//Handlers Own an HTTP concern — e.g. routes, rendering responses, returning templates or JSON. Injected dependencies (cfg, db, etc.). Should use helpers, not vice versa.
import (
"net/http"
templateHelpers "synlotto-website/internal/helpers/template"
)
// RenderError delegates to the helper's RenderError, ensuring handlers remain
// the entry point for rendering HTTP responses.
func (h *Handler) RenderError(w http.ResponseWriter, r *http.Request, statusCode int) {
templateHelpers.RenderError(w, r, statusCode)
}