package main
import(
"github.com/kataras/iris"
"github.com/kataras/iris/middleware/logger"
"github.com/kataras/iris/middleware/recover"
)
type User struct{
Name string `json:"name"`
Age int `json:"age"`
}
func main(){
app := iris.New()
app.Logger().SetLevel("debug")
app.Use(recover.New())
app.Use(logger.New())
app.Post("/user", func(ctx iris.Context){
c := &User{}
if err := ctx.ReadJSON(c); err != nil{
panic(err.Error())
}else{
ctx.JSON(c)
}
})
app.Run(iris.Addr(":8080"), iris.WithoutServerError(iris.ErrServerClosed))
}