Exemplo n.º 1
0
//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)

	})

}
Exemplo n.º 2
0
//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)

}
Exemplo n.º 3
0
//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)

}
Exemplo n.º 4
0
		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"))

	})

})