004-Go iris 接收post json数据

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))
}
上一篇:Spark中repartition和partitionBy的区别


下一篇:ajax 参数记录