Querystring parameters

  1. func main() {
  2. app := iris.Default()
  3. // Query string parameters are parsed using the existing underlying request object.
  4. // The request responds to a url matching: /welcome?firstname=Jane&lastname=Doe
  5. app.Get("/welcome", func(ctx iris.Context) {
  6. firstname := ctx.URLParamDefault("firstname", "Guest")
  7. lastname := ctx.URLParam("lastname") // shortcut for ctx.Request().URL.Query().Get("lastname")
  8. ctx.Writef("Hello %s %s", firstname, lastname)
  9. })
  10. app.Listen(":8080")
  11. }