go语言 iris之hello world

六眼飞鱼酱① 提交于 2019-11-26 20:35:13

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"))
}

学习地址:https://www.studyiris.com/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!