Skip to content Search Apps Documentation Source Content Run Reset Eval Playground File Folder Download Copy Actions State String Boolean Number Struct Map Slice Pointer Function Closure Reference Nil Package Type Interface Unknown

handler.gno

0.95 Kb · 26 lines
 1package mux
 2
 3// Handler stores a route pattern with one of two handler shapes.
 4// Fn (HandlerFunc, no rlm) is set by HandleFunc; FnRlm (HandlerFuncRlm,
 5// rlm-aware non-crossing) is set by HandleFuncRlm. Exactly one is set
 6// per route. RenderRlm dispatches FnRlm with the supplied rlm; Render
 7// dispatches Fn and panics if the matched route was registered with
 8// HandleFuncRlm (caller used the wrong dispatch method).
 9type Handler struct {
10	Pattern string
11	Fn      HandlerFunc
12	FnRlm   HandlerFuncRlm
13}
14
15type HandlerFunc func(*ResponseWriter, *Request)
16
17// HandlerFuncRlm is the rlm-aware handler shape — non-crossing
18// (`_ int, rlm realm` first params) so callers thread cur as data
19// for the handler to forward to downstream crossing functions.
20type HandlerFuncRlm func(_ int, rlm realm, res *ResponseWriter, req *Request)
21
22type ErrHandlerFunc func(*ResponseWriter, *Request) error
23
24type NotFoundHandler func(*ResponseWriter, *Request)
25
26// TODO: AutomaticIndex