mirror of
https://gitee.com/johng/gf
synced 2026-07-01 19:31:23 +08:00
24 lines
413 B
Go
24 lines
413 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gogf/gf/frame/g"
|
|
"github.com/gogf/gf/net/ghttp"
|
|
)
|
|
|
|
func MiddlewareCORS(r *ghttp.Request) {
|
|
r.Response.CORSDefault()
|
|
r.Middleware.Next()
|
|
}
|
|
|
|
func main() {
|
|
s := g.Server()
|
|
s.Group("/api.v2", func(group *ghttp.RouterGroup) {
|
|
group.Middleware(MiddlewareCORS)
|
|
group.ALL("/user/list", func(r *ghttp.Request) {
|
|
r.Response.Write("list")
|
|
})
|
|
})
|
|
s.SetPort(8199)
|
|
s.Run()
|
|
}
|