//FormParser parse the url query variables and Body of a request. //If parsing is succesful then the data can be retrieved via pelau.Request.Get() func FormParser(req pelau.Request, res pelau.Response, ctx *pelau.Context) { req.Raw(func(modReq *pelau.ModifiedRequest) { err := modReq.ParseForm() if err != nil { req.Error(err, nil) } ctx.Next(req, res, ctx) }) }
//JSONOutput adds JSON encoding support to the Response object. func JSONOutput(req pelau.Request, res pelau.Response, ctx *pelau.Context) { ctx.Next(req, &JSONResponse{res}, ctx) }
//JSONInput adds JSON encoding support to the Response object. func JSONInput(req pelau.Request, res pelau.Response, ctx *pelau.Context) { ctx.Next(&JSONRequest{req}, res, ctx) }
var a, b, c string ctx.Add(func(req pelau.Request, res pelau.Response, cx *pelau.Context) { a = "A" cx.Next(req, res, cx) }) ctx.Add(func(req pelau.Request, res pelau.Response, cx *pelau.Context) { b = "B" cx.Next(req, res, cx) }) ctx.Add(func(req pelau.Request, res pelau.Response, cx *pelau.Context) { c = "C" cx.Next(req, res, cx) }) ctx.Next(req, res, ctx) Expect(a + b + c).Should(Equal("ABC")) }) })