Using HandlerFuncs

HandlerFuncs should implement the Serve(Context) func. HandlerFunc is the most simple method to register a route or a middleware, but under the hood it acts like a Handler. It implements the Handler interface as well:

type HandlerFunc func(*Context)

func (h HandlerFunc) Serve(c *Context) {

HandlerFuncs shoud have this function signature:

func handlerFunc(ctx *iris.Context)  {

iris.Get("/letsgetit", handlerFunc)
iris.Post("/letspostit", handlerFunc)
iris.Put("/letputit", handlerFunc)
iris.Delete("/letsdeleteit", handlerFunc)

results matching ""

    No results matching ""