Documentation
¶
Index ¶
- func Forbidden(message string, cause error) error
- func HandlerErrorMessage(err error, status int) string
- func HandlerStatus(err error, fallback int) int
- func HandlerUserMessage(err error, status int) i18n.UserMessage
- func IsRequestBodyTooLarge(err error) bool
- func LocalizeValidation(result validation.Result, bundle i18n.ErrorBundle, locale string) validation.Result
- func LocalizedHandlerErrorMessage(err error, status int, bundle i18n.ErrorBundle, locale string) string
- func NewCodedHandlerError(status int, code, message string, vars map[string]string, cause error) error
- func NewExpectedCode(kind ErrorKind, code, message string, vars map[string]string, cause error) error
- func NewExpectedError(kind ErrorKind, message string, cause error) error
- func NewHandlerError(status int, message string, cause error) error
- func NotFound(message string, cause error) error
- func ServerError(message string, cause error) error
- func ValidateLocalRedirect(url string) error
- func ValidationFailed(message string, cause error) error
- func ValidationHTML(result validation.Result) string
- func WriteHTML(writer http.ResponseWriter, request *http.Request, body string, ...) error
- func WriteHTTP(writer http.ResponseWriter, result Response) error
- func WriteNoStoreError(writer http.ResponseWriter, status int, message string)
- func WriteNoStoreHTML(writer http.ResponseWriter, request *http.Request, body string) error
- func WriteNoStoreHTTP(writer http.ResponseWriter, result Response) error
- func WriteNoStoreHandlerError(writer http.ResponseWriter, err error, fallbackStatus int)
- func WriteNoStoreHandlerJSONError(writer http.ResponseWriter, err error, fallbackStatus int)
- func WriteNoStoreJSONError(writer http.ResponseWriter, status int, message string)
- func WriteNoStoreJSONUserError(writer http.ResponseWriter, status int, code, message string)
- func WriteNoStoreLocalizedHandlerError(writer http.ResponseWriter, err error, fallbackStatus int, ...)
- func WriteNoStoreLocalizedHandlerJSONError(writer http.ResponseWriter, err error, fallbackStatus int, ...)
- func WriteNoStoreLocalizedJSONUserError(writer http.ResponseWriter, status int, code, message string, ...)
- func WriteNoStoreLocalizedUserError(writer http.ResponseWriter, status int, code, message string, ...)
- func WriteNoStoreUserError(writer http.ResponseWriter, status int, code, message string)
- type ErrorKind
- type HandlerError
- type Kind
- type Response
- func FragmentFor(target, body string) Response
- func FragmentSwap(target string, swap SwapMode, body string) (Response, error)
- func HTMLBody(status int, body string) Response
- func JSONBody(status int, body string) Response
- func JSONValue(status int, value any) (Response, error)
- func LocalizedValidationFragment(target string, result validation.Result, bundle i18n.ErrorBundle, ...) Response
- func RedirectTo(url string) Response
- func ReloadPage() Response
- func ValidationFragment(target string, result validation.Result) Response
- func ValidationJSON(result validation.Result) (Response, error)
- func WithCookie(result Response, cookie http.Cookie) Response
- type SwapMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Forbidden ¶ added in v0.8.0
Forbidden creates an expected HTTP 403 error for generated boundaries.
func HandlerErrorMessage ¶ added in v0.5.0
HandlerErrorMessage returns the client-facing message for a generated handler error. Ordinary 5xx failures use generic status text so internal details stay out of HTTP responses. HandlerError.Message remains an explicit application-owned override.
func HandlerStatus ¶
HandlerStatus returns a handler error status, or fallback for ordinary errors.
func HandlerUserMessage ¶ added in v0.13.0
func HandlerUserMessage(err error, status int) i18n.UserMessage
HandlerUserMessage returns the stable code/default/vars payload for err.
func IsRequestBodyTooLarge ¶ added in v0.13.0
IsRequestBodyTooLarge reports whether err contains the typed error returned by http.MaxBytesReader after a request exceeds its configured limit.
func LocalizeValidation ¶ added in v0.13.0
func LocalizeValidation(result validation.Result, bundle i18n.ErrorBundle, locale string) validation.Result
LocalizeValidation resolves validation messages through the typed catalog.
func LocalizedHandlerErrorMessage ¶ added in v0.13.0
func LocalizedHandlerErrorMessage(err error, status int, bundle i18n.ErrorBundle, locale string) string
LocalizedHandlerErrorMessage resolves an expected handler error through bundle.
func NewCodedHandlerError ¶ added in v0.13.0
func NewCodedHandlerError(status int, code, message string, vars map[string]string, cause error) error
NewCodedHandlerError creates an expected handler failure with a stable code.
func NewExpectedCode ¶ added in v0.13.0
func NewExpectedCode(kind ErrorKind, code, message string, vars map[string]string, cause error) error
NewExpectedCode creates an expected typed error with an app-owned stable code.
func NewExpectedError ¶ added in v0.8.0
NewExpectedError creates a typed application-owned error for generated boundaries. The message is client-facing; do not include secrets or internal service details.
func NewHandlerError ¶
NewHandlerError creates an error suitable for generated handlers.
func NotFound ¶ added in v0.8.0
NotFound creates an expected HTTP 404 error for generated boundaries.
func ServerError ¶ added in v0.8.0
ServerError creates an expected HTTP 500 error for generated boundaries.
func ValidateLocalRedirect ¶ added in v0.5.0
ValidateLocalRedirect reports whether url is a safe same-origin redirect target. Only local absolute paths are allowed; protocol-relative URLs, backslash tricks browsers normalize to "//", and CRLF header-injection attempts are rejected. It is the single redirect-safety contract shared by the response, guard, and SSR lanes so an attacker-influenced "next"/"return_to" value cannot become an open redirect.
func ValidationFailed ¶ added in v0.8.0
ValidationFailed creates an expected HTTP 422 error for generated boundaries.
func ValidationHTML ¶ added in v0.1.5
func ValidationHTML(result validation.Result) string
ValidationHTML renders a small escaped validation message block.
func WriteHTML ¶ added in v0.1.5
func WriteHTML(writer http.ResponseWriter, request *http.Request, body string, cacheControl string) error
WriteHTML writes an HTML response with an explicit Cache-Control policy and suppresses the body for HEAD requests. An empty cache policy falls back to no-store for request-time safety.
func WriteHTTP ¶
func WriteHTTP(writer http.ResponseWriter, result Response) error
WriteHTTP writes a runtime response envelope to net/http.
func WriteNoStoreError ¶
func WriteNoStoreError(writer http.ResponseWriter, status int, message string)
WriteNoStoreError writes an HTTP error that must not be cached.
func WriteNoStoreHTML ¶
WriteNoStoreHTML writes a no-store HTML response and suppresses the body for HEAD requests.
func WriteNoStoreHTTP ¶
func WriteNoStoreHTTP(writer http.ResponseWriter, result Response) error
WriteNoStoreHTTP writes a response envelope that must not be cached.
func WriteNoStoreHandlerError ¶ added in v0.5.0
func WriteNoStoreHandlerError(writer http.ResponseWriter, err error, fallbackStatus int)
WriteNoStoreHandlerError writes a generated handler error using the client-safe HandlerErrorMessage policy.
func WriteNoStoreHandlerJSONError ¶ added in v0.5.0
func WriteNoStoreHandlerJSONError(writer http.ResponseWriter, err error, fallbackStatus int)
WriteNoStoreHandlerJSONError writes a generated handler error as the stable JSON shape used by contract web adapters.
func WriteNoStoreJSONError ¶ added in v0.5.0
func WriteNoStoreJSONError(writer http.ResponseWriter, status int, message string)
WriteNoStoreJSONError writes the stable generated JSON error shape.
func WriteNoStoreJSONUserError ¶ added in v0.13.0
func WriteNoStoreJSONUserError(writer http.ResponseWriter, status int, code, message string)
WriteNoStoreJSONUserError writes the stable code/message JSON error shape.
func WriteNoStoreLocalizedHandlerError ¶ added in v0.13.0
func WriteNoStoreLocalizedHandlerError(writer http.ResponseWriter, err error, fallbackStatus int, bundle i18n.ErrorBundle, locale string)
WriteNoStoreLocalizedHandlerError localizes an expected handler error.
func WriteNoStoreLocalizedHandlerJSONError ¶ added in v0.13.0
func WriteNoStoreLocalizedHandlerJSONError(writer http.ResponseWriter, err error, fallbackStatus int, bundle i18n.ErrorBundle, locale string)
WriteNoStoreLocalizedHandlerJSONError is the structured JSON counterpart.
func WriteNoStoreLocalizedJSONUserError ¶ added in v0.13.0
func WriteNoStoreLocalizedJSONUserError(writer http.ResponseWriter, status int, code, message string, vars map[string]string, bundle i18n.ErrorBundle, locale string)
WriteNoStoreLocalizedJSONUserError resolves a coded JSON error through bundle.
func WriteNoStoreLocalizedUserError ¶ added in v0.13.0
func WriteNoStoreLocalizedUserError(writer http.ResponseWriter, status int, code, message string, vars map[string]string, bundle i18n.ErrorBundle, locale string)
WriteNoStoreLocalizedUserError resolves a coded default through bundle.
func WriteNoStoreUserError ¶ added in v0.13.0
func WriteNoStoreUserError(writer http.ResponseWriter, status int, code, message string)
WriteNoStoreUserError writes safe text and exposes its stable code in a response header for non-JSON clients.
Types ¶
type ErrorKind ¶ added in v0.8.0
type ErrorKind string
ErrorKind identifies expected application-owned error categories that generated request-time lanes can map to HTTP status codes.
type HandlerError ¶
HandlerError wraps failures raised by generated handlers.
func (HandlerError) Error ¶
func (err HandlerError) Error() string
func (HandlerError) Unwrap ¶
func (err HandlerError) Unwrap() error
type Kind ¶
type Kind string
Kind identifies the response shape produced by actions, fragments, APIs, or full-page rendering.
type Response ¶
type Response struct {
Kind Kind
Status int
Body string
Target string
Swap SwapMode
URL string
Cookies []http.Cookie
}
Response is the generated runtime response envelope.
func FragmentFor ¶
FragmentFor creates a partial fragment response for a DOM target.
func FragmentSwap ¶
FragmentSwap creates a partial fragment response with an explicit swap mode.
func LocalizedValidationFragment ¶ added in v0.13.0
func LocalizedValidationFragment(target string, result validation.Result, bundle i18n.ErrorBundle, locale string) Response
LocalizedValidationFragment resolves coded field errors before rendering.
func ReloadPage ¶ added in v0.1.5
func ReloadPage() Response
ReloadPage asks enhanced clients to reload the current page. Non-enhanced forms should still use normal POST/redirect/get behavior.
func ValidationFragment ¶ added in v0.1.5
func ValidationFragment(target string, result validation.Result) Response
ValidationFragment creates a fragment response with escaped validation messages. It uses HTTP 200 so progressively enhanced partial forms can swap the returned fragment with the current client runtime.
func ValidationJSON ¶ added in v0.1.5
func ValidationJSON(result validation.Result) (Response, error)
ValidationJSON creates a structured validation error response.