Documentation
¶
Overview ¶
Package handler is the highest level module of the macro package which makes use the rest of the macro package, it is mainly used, internally, by the router package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CanMakeHandler ¶
CanMakeHandler reports whether a macro template needs a special macro's evaluator handler to be validated before procceed to the next handler(s). If the template does not contain any dynamic attributes and a special handler is NOT required then it returns false.
func MakeFilter ¶
MakeFilter returns a Filter which reports whether a specific macro template and its parameters pass the serve-time validation.
func MakeHandler ¶
MakeHandler creates and returns a handler from a macro template, the handler evaluates each of the parameters if necessary at all. It always returns a non-nil handler, therefore the caller MUST check `CanMakeHandler` first: if the template does not contain any dynamic attributes and a special handler is NOT required then `MakeFilter` returns a nil filter and the returned handler panics on the first request.
Types ¶
type ParamErrorHandler ¶
ParamErrorHandler is a special type of Iris handler which receives any error produced by a path type parameter evaluator and let developers customize the output instead of the provided error code 404 or anyother status code given on the `else` literal.
Note that the builtin macros return error too, but they're handled by the `else` literal (error code). To change this behavior and send a custom error response you have to register it:
app.Macros().Get("uuid").SetErrorHandler(func(ctx iris.Context, paramIndex int, err error) {
// ...
})
You can also set custom macros by `app.Macros().Register`.
See macro.Macro.SetErrorHandler to set it for a single macro and macro.Macros.SetErrorHandler to set it for all of them.
var DefaultErrorHandler ParamErrorHandler = nil