func handler(req pelau.Request, res pelau.Response) { fmt.Printf("[%s] request detected on path %s.\n", req.Raw().Method, req.Raw().URL.Path) fmt.Printf("Printing Submatches: %v\n", req.Params()) res.Head("X-Men", "Was a good show") // res.Header("Content-Type", "application/json") res.Send(struct{ FIELD string }{"NAME"}) }
//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) }) }