1、安装
iris安装要求golang版本至少为1.8,建议1.9
# go get -u github.com/kataras/iris
简单的hello world程序
package main
import (
"github.com/kataras/iris"
// "github.com/kataras/iris/context"
)
func main(){
app := iris.New()
//app.Get("/",func(ctx context.Context){})
app.Handle("Get","/",func(ctx iris.Context){
ctx.HTML("hello world")
})
app.Get("/ping",func(ctx iris.Context){
ctx.WriteString("pong")
})
app.Get("/hello", func(ctx iris.Context) {
ctx.JSON(iris.Map{"message": "Hello iris web framework."})
})
app.Run(iris.Addr(":8080"))
}
来源:CSDN
作者:qq_21127151
链接:https://blog.csdn.net/qq_21127151/article/details/83664043