5、golang 的http请求
package api
import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/context"
)
/**
title 给app添加路由
@param app *iris.Application iris创建的结构体对象
@return
*/
func Routing(app *iris.Application) {
testRouting(app)
getRouting(app)
postRouting(app)
putRouting(app)
deleteRouting(app)
}
func testRouting(app *iris.Application) {
//url: http://localhost:8000/getRequest
//type:GET请求
app.Get("getRequest", func(context context.Context) {
path:=context.Path()
app.Logger().Info(path)
})
//url: http://localhost:/user/info
//type:POST请求
app.Handle("POST", "/user/info", func(context context.Context) {
context.WriteString(" User Info is Post Request , Deal is in handle func ")
path:=context.Path()
app.Logger().Info(path)
})
}