mirror of
https://gitee.com/johng/gf.git
synced 2024-12-04 13:18:01 +08:00
41 lines
934 B
Go
41 lines
934 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gogf/gf/frame/g"
|
|
"github.com/gogf/gf/net/ghttp"
|
|
)
|
|
|
|
func main() {
|
|
s := g.Server()
|
|
s.Group("/api.v2", func(g *ghttp.RouterGroup) {
|
|
g.Middleware(func(r *ghttp.Request) {
|
|
r.Response.Write("start")
|
|
r.Middleware.Next()
|
|
r.Response.Write("end")
|
|
})
|
|
g.Group("/order", func(g *ghttp.RouterGroup) {
|
|
g.GET("/list", func(r *ghttp.Request) {
|
|
r.Response.Write("list")
|
|
})
|
|
})
|
|
g.Group("/user", func(g *ghttp.RouterGroup) {
|
|
g.GET("/info", func(r *ghttp.Request) {
|
|
r.Response.Write("info")
|
|
})
|
|
g.POST("/edit", func(r *ghttp.Request) {
|
|
r.Response.Write("edit")
|
|
})
|
|
})
|
|
g.Group("/hook", func(g *ghttp.RouterGroup) {
|
|
g.Hook("/*", ghttp.HOOK_BEFORE_SERVE, func(r *ghttp.Request) {
|
|
r.Response.Write("hook any")
|
|
})
|
|
g.Hook("/:name", ghttp.HOOK_BEFORE_SERVE, func(r *ghttp.Request) {
|
|
r.Response.Write("hook name")
|
|
})
|
|
})
|
|
})
|
|
s.SetPort(8199)
|
|
s.Run()
|
|
}
|