golazy.dev
–
golazy.dev
/
controller
Index
|
Files
package controller
import "golazy.dev/controller"
Functions
func Bind[T any]
func Bind[T any](
ctx context.Context,
factory Factory[T],
action func(*T, http.ResponseWriter, *http.Request) error,
) http.Handler
func Error
func Error(status int, err error) error
func Handle
func Handle(action Action) http.Handler
func WithRenderer
func WithRenderer(ctx context.Context, renderer *Renderer) context.Context
func WithWriter
func WithWriter(ctx context.Context, writer http.ResponseWriter) context.Context
Types
type Action
type Action func(http.ResponseWriter, *http.Request) error
type Base
type Base struct {
// contains filtered or unexported fields
}
func NewBase
func NewBase(ctx context.Context, viewPath string) (Base, error)
func (b *Base) Render
func (b *Base) Render(view string) error
func (b *Base) Set
func (b *Base) Set(name string, value any)
func (b *Base) SetLayout
func (b *Base) SetLayout(layout string)
type Factory
type Factory[T any] func(context.Context) (*T, error)
type HTTPError
type HTTPError struct {
Status int
Err error
}
func (e *HTTPError) Error
func (e *HTTPError) Error() string
func (e *HTTPError) Unwrap
func (e *HTTPError) Unwrap() error
type Renderer
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer
func NewRenderer(views fs.FS) (*Renderer, error)