Another example: query + post form

  1. POST /post?id=1234&page=1 HTTP/1.1
  2. Content-Type: application/x-www-form-urlencoded
  3. name=kataras&message=this_is_great
  1. func main() {
  2. app := iris.Default()
  3. app.Post("/post", func(ctx iris.Context) {
  4. id, err := ctx.URLParamInt("id", 0)
  5. if err != nil {
  6. ctx.StopWithError(iris.StatusBadRequest, err)
  7. return
  8. }
  9. page := ctx.URLParamIntDefault("page", 0)
  10. name := ctx.PostValue("name")
  11. message := ctx.PostValue("message")
  12. ctx.Writef("id: %d; page: %d; name: %s; message: %s", id, page, name, message)
  13. })
  14. app.Listen(":8080")
  15. }
  1. id: 1234; page: 1; name: kataras; message: this_is_great