娱乐网站建设怎么样,关键词seo排名怎么选,网站百度百科,优化的定义继初步了解iris后 文章目录 获取url路径获取数据get请求post请求获取JSON数据格式JSON返回值获取XML数据格式XML返回值 获取url路径
package mainimport github.com/kataras/iris/v12func main(){app : iris.New()app.Get(/hello,func(ctx iris.Conte…继初步了解iris后 文章目录 获取url路径获取数据get请求post请求获取JSON数据格式JSON返回值获取XML数据格式XML返回值 获取url路径
package mainimport github.com/kataras/iris/v12func main(){app : iris.New()app.Get(/hello,func(ctx iris.Context){path : context.Path()app.Logger().Info(path)context.WriteString(请求路径,path)})app.Listen(:82)
} 获取数据
get请求
app.Get(/userinfo,func(ctx iris.Context){//path : ctx.Path()userName : ctx.URLParam(username)pwd : ctx.URLParam(pwd)if(userNameadminpwd123456){ctx.HTML(h1userName welcome /h1)}else{ctx.HTML(h1plase register again/h1)}
})
post请求
app.Post(/postLogin,func(ctx iris.Context){name : ctx.PostValue(name)pwd : ctx.PostValue(pwd)app.Logger().Info(name, ,pwd)ctx.HTML(name)
})获取JSON数据格式
iris.Context.ReadJSON() //用来读取JSON返回值
iris.Context.JSON()获取XML数据格式
iris.Context.ReadXML()XML返回值
iris.Context.XML()