mirror of
https://github.com/kataras/iris.git
synced 2025-01-24 03:01:03 +01:00
3945fa68d1
We have to do the same on iris-contrib/examples, iris-contrib/middleware and e.t.c. Former-commit-id: 0860688158f374bc137bc934b81b26dcd0e10964
30 lines
606 B
Go
30 lines
606 B
Go
// package main contains an example on how to use the ReadForm, but with the same way you can do the ReadJSON & ReadJSON
|
|
package main
|
|
|
|
import (
|
|
"github.com/kataras/iris/v12"
|
|
)
|
|
|
|
type MyType struct {
|
|
Name string `url:"name"`
|
|
Age int `url:"age"`
|
|
}
|
|
|
|
func main() {
|
|
app := iris.New()
|
|
|
|
app.Get("/", func(ctx iris.Context) {
|
|
var t MyType
|
|
err := ctx.ReadQuery(&t)
|
|
if err != nil && !iris.IsErrPath(err) {
|
|
ctx.StatusCode(iris.StatusInternalServerError)
|
|
ctx.WriteString(err.Error())
|
|
}
|
|
|
|
ctx.Writef("MyType: %#v", t)
|
|
})
|
|
|
|
// http://localhost:8080?name=iris&age=3
|
|
app.Run(iris.Addr(":8080"))
|
|
}
|