1 Star 0 Fork 0

哪吒闹海 / Moutai

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.go 678 Bytes
一键复制 编辑 原始数据 按行查看 历史
likeran 提交于 2020-12-15 12:00 . 实现recover中间件
package main
import "net/http"
import "./moutai"
func main() {
r := moutai.Default()
v1 := r.Group("/v1")
{
v1.GET("/hello", func(c *moutai.Context) {
// expect /hello?name=lkrMacBookAir
c.String(http.StatusOK, "hello %s, you're at %s\n", c.Query("name"), c.Path)
})
}
v2 := r.Group("/v2")
{
v2.GET("/hello/:name", func(c *moutai.Context) {
// expect /hello/lkrMacBookAir
c.String(http.StatusOK, "hello %s, you're at %s\n", c.Param("name"), c.Path)
})
v2.POST("/login", func(c *moutai.Context) {
c.JSON(http.StatusOK, moutai.H{
"username": c.PostForm("username"),
"password": c.PostForm("password"),
})
})
}
r.Run(":9999")
}
Go
1
https://gitee.com/keran94/Moutai.git
git@gitee.com:keran94/Moutai.git
keran94
Moutai
Moutai
master

搜索帮助