Documentation
¶
Index ¶
- func BindBody(c *Context, dst any) error
- func BindPathParams(c *Context, dst any) error
- func BindQueryParams(c *Context, dst any) error
- func Environment() string
- func LoadConfig[T any](environment string, configFS fs.FS) (*T, error)
- func MergeFS(roots ...fs.FS) fs.FS
- func MergeSpurAssets(hostAssets fs.FS, mounts ...Mount) fs.FS
- func MergeSpurManifests(hostManifest assets.Manifest, mounts ...Mount) (assets.Manifest, error)
- func MergeSpurViews(hostViews fs.FS, mounts ...Mount) fs.FS
- func RegisterSpurJobs(reg *jobs.Registry, mounts ...Mount)
- func RegisterSpurRoutes(r *Router, mounts ...Mount)
- type AssetsStrategy
- type Binder
- type Context
- func (c *Context) Bind(target any) error
- func (c *Context) Blob(code int, contentType string, b []byte) error
- func (c *Context) Context() context.Context
- func (c *Context) Get[T any](key string) T
- func (c *Context) HTML(code int, html string) error
- func (c *Context) HTMLBlob(code int, blob []byte) error
- func (c *Context) JSON(code int, j any) error
- func (c *Context) Logger() *slog.Logger
- func (c *Context) Render(code int, name string, data any) error
- func (c *Context) Request() *http.Request
- func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
- func (c *Context) Response() http.ResponseWriter
- func (c *Context) Set(key string, val any)
- func (c *Context) String(code int, s string) error
- type DefaultBinder
- type ErrorHandlerFunc
- type Group
- func (g *Group) Delete(pattern string, h HandlerFunc)
- func (g *Group) Get(pattern string, h HandlerFunc)
- func (g *Group) HandleFunc(method, pattern string, h HandlerFunc)
- func (g *Group) NewGroup(prefix string, mws ...MiddlewareFunc) *Group
- func (g *Group) Patch(pattern string, h HandlerFunc)
- func (g *Group) Post(pattern string, h HandlerFunc)
- func (g *Group) Put(pattern string, h HandlerFunc)
- func (g *Group) Resource(prefix string, r Resource, mw ...MiddlewareFunc)
- func (g *Group) Resources(prefix string, r Resources, mw ...MiddlewareFunc)
- func (g *Group) Use(mws ...MiddlewareFunc)
- func (g *Group) WithGroup(prefix string, fn GroupBuilder, mws ...MiddlewareFunc)
- type GroupBuilder
- type HTTPError
- type HandlerFunc
- type MiddlewareFunc
- type Mount
- type Renderer
- type Resource
- type Resources
- type RouteBuilder
- type Router
- func (rt *Router) Delete(pattern string, h HandlerFunc)
- func (rt *Router) Get(pattern string, h HandlerFunc)
- func (rt *Router) HandleFunc(method, pattern string, h HandlerFunc)
- func (rt *Router) NewGroup(prefix string, mws ...MiddlewareFunc) *Group
- func (rt *Router) Patch(pattern string, h HandlerFunc)
- func (rt *Router) Post(pattern string, h HandlerFunc)
- func (rt *Router) Put(pattern string, h HandlerFunc)
- func (rt *Router) Resource(prefix string, r Resource, mw ...MiddlewareFunc)
- func (rt *Router) Resources(prefix string, r Resources, mw ...MiddlewareFunc)
- func (rt *Router) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (rt *Router) Use(mws ...MiddlewareFunc)
- func (rt *Router) WithGroup(prefix string, fn GroupBuilder, mws ...MiddlewareFunc)
- type Runner
- type Spur
- type Trail
- type TrailOptions
- type Unmarshaler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindPathParams ¶
func BindQueryParams ¶
func Environment ¶
func Environment() string
func MergeSpurManifests ¶
func RegisterSpurJobs ¶
func RegisterSpurRoutes ¶
Types ¶
type AssetsStrategy ¶
type AssetsStrategy string
const ( AssetsStrategyImportMap AssetsStrategy = "importmap" AssetsStrategyBundler AssetsStrategy = "bundler" AssetsStrategyNone AssetsStrategy = "none" )
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) Response ¶
func (c *Context) Response() http.ResponseWriter
type DefaultBinder ¶
type DefaultBinder struct{}
type ErrorHandlerFunc ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Delete ¶
func (g *Group) Delete(pattern string, h HandlerFunc)
func (*Group) Get ¶
func (g *Group) Get(pattern string, h HandlerFunc)
func (*Group) HandleFunc ¶
func (g *Group) HandleFunc(method, pattern string, h HandlerFunc)
func (*Group) Patch ¶
func (g *Group) Patch(pattern string, h HandlerFunc)
func (*Group) Post ¶
func (g *Group) Post(pattern string, h HandlerFunc)
func (*Group) Put ¶
func (g *Group) Put(pattern string, h HandlerFunc)
func (*Group) Resources ¶
func (g *Group) Resources(prefix string, r Resources, mw ...MiddlewareFunc)
func (*Group) Use ¶
func (g *Group) Use(mws ...MiddlewareFunc)
func (*Group) WithGroup ¶
func (g *Group) WithGroup(prefix string, fn GroupBuilder, mws ...MiddlewareFunc)
type GroupBuilder ¶
type GroupBuilder func(g *Group)
type HTTPError ¶
func NewHTTPError ¶
type HandlerFunc ¶
type MiddlewareFunc ¶
type MiddlewareFunc func(next HandlerFunc) HandlerFunc
type RouteBuilder ¶
type RouteBuilder func(r *Router)
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Delete ¶
func (rt *Router) Delete(pattern string, h HandlerFunc)
func (*Router) Get ¶
func (rt *Router) Get(pattern string, h HandlerFunc)
func (*Router) HandleFunc ¶
func (rt *Router) HandleFunc(method, pattern string, h HandlerFunc)
func (*Router) Patch ¶
func (rt *Router) Patch(pattern string, h HandlerFunc)
func (*Router) Post ¶
func (rt *Router) Post(pattern string, h HandlerFunc)
func (*Router) Put ¶
func (rt *Router) Put(pattern string, h HandlerFunc)
func (*Router) Resource ¶
func (rt *Router) Resource(prefix string, r Resource, mw ...MiddlewareFunc)
func (*Router) Resources ¶
func (rt *Router) Resources(prefix string, r Resources, mw ...MiddlewareFunc)
func (*Router) Use ¶
func (rt *Router) Use(mws ...MiddlewareFunc)
func (*Router) WithGroup ¶
func (rt *Router) WithGroup(prefix string, fn GroupBuilder, mws ...MiddlewareFunc)
type Runner ¶
Runner is a background loop a host app needs kept alive alongside the HTTP server — e.g. a polling Broadcaster's delivery loop, or a jobs.Backend's worker loop. Run must return once ctx is cancelled; see Trail.Run and RegisterSpurRunners.
func RegisterSpurRunners ¶
RegisterSpurRunners collects the background Runner for every mounted Spur that has one (e.g. a channels.Backend wrapping a polling Broadcaster). Spurs with nothing to run are silently skipped. Pass the result as TrailOptions.Runners so Trail.Run starts and stops them alongside the HTTP server.
type Trail ¶
func New ¶
func New(o *TrailOptions) (*Trail, error)
func (*Trail) Use ¶
func (t *Trail) Use(mws ...MiddlewareFunc)
type TrailOptions ¶
type TrailOptions struct {
Context context.Context
Logger *slog.Logger
ViewFS fs.FS
AssetsFS fs.FS
ConfigFS fs.FS
ErrorHandler ErrorHandlerFunc
RouteBuilder RouteBuilder
Renderer Renderer
Binder Binder
LayoutName string
Host string
Port int
AssetsStrategy AssetsStrategy
// Runners are started as background goroutines alongside the HTTP
// server by Trail.Run, and stopped on the same shutdown signal —
// typically built via RegisterSpurRunners(mounts...).
Runners []Runner
}
func WithDefaultOptions ¶
func WithDefaultOptions(opts *TrailOptions) *TrailOptions
type Unmarshaler ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
trails
command
|
|
|
internal
|
|
|
driver/mysql
module
|
|
|
driver/postgres
module
|
|
|
driver/sqlite
module
|
Click to show internal directories.
Click to hide internal directories.