Documentation
¶
Index ¶
- func Handler(h HandlerFunc) http.HandlerFunc
- func NotFoundHandler() http.HandlerFunc
- func UseErrorHandler(h ErrorHandlerFunc)
- type ErrorHandlerFunc
- type HandlerFunc
- type Kit
- func (k *Kit) Authorization() (string, error)
- func (k *Kit) Bytes(status int, b []byte) error
- func (k *Kit) Decode(v any) error
- func (k *Kit) GetContext(key string) string
- func (k *Kit) GetCookie(key string) (string, error)
- func (k *Kit) GetHeader(key string) string
- func (k *Kit) HTML(status int, htmlContent string) error
- func (k *Kit) IsAjax() bool
- func (k *Kit) JSON(status int, v any) error
- func (k *Kit) NoContent() error
- func (k *Kit) PathValue(key string) string
- func (k *Kit) Redirect(url string) error
- func (k *Kit) Render(name string, data any) error
- func (k *Kit) RenderPartial(name string, data any) error
- func (k *Kit) RenderTemplate(name string, data any) error
- func (k *Kit) SetContext(key, value string)
- func (k *Kit) SetCookie(key, value string)
- func (k *Kit) Text(status int, msg string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(h HandlerFunc) http.HandlerFunc
Handler converts a Kit.HandlerFunc to an http.HandlerFunc
func NotFoundHandler ¶
func NotFoundHandler() http.HandlerFunc
NotFoundHandler returns a handler for 404 errors
func UseErrorHandler ¶
func UseErrorHandler(h ErrorHandlerFunc)
UseErrorHandler sets a custom error handler for all Kit handlers
Types ¶
type ErrorHandlerFunc ¶
ErrorHandlerFunc is the signature for custom error handlers
type HandlerFunc ¶
HandlerFunc is the signature for Twine handlers that return errors
type Kit ¶
type Kit struct {
Response http.ResponseWriter
Request *http.Request
}
Kit wraps http.ResponseWriter and *http.Request for convenient access
func (*Kit) Authorization ¶
Authorization extracts the authorization token from cookie or header
func (*Kit) GetContext ¶
GetContext retrieves a context value from the request
func (*Kit) Render ¶
Render automatically chooses between full and partial rendering based on X-Alpine-Request header
func (*Kit) RenderPartial ¶
RenderPartial renders a template component (for Ajax partial responses)
func (*Kit) RenderTemplate ¶
RenderTemplate renders a full page template
func (*Kit) SetContext ¶
SetContext sets a context value on the request