router.go 647 B

1234567891011121314151617181920212223242526272829
  1. package router
  2. import (
  3. "gfast/app/common/api"
  4. _ "gfast/app/system/router"
  5. "gfast/middleware"
  6. "github.com/gogf/gf/frame/g"
  7. "github.com/gogf/gf/net/ghttp"
  8. )
  9. func init() {
  10. s := g.Server()
  11. //跨域处理
  12. s.Use(middleware.CORS)
  13. // 添加URI与静态目录的映射
  14. s.AddStaticPath("/static", g.Cfg().GetString("server.ServerRoot"))
  15. s.Group("/", func(group *ghttp.RouterGroup) {
  16. //上传的文件允许跨域请求
  17. group.Hook("/pub_upload/*", ghttp.HookBeforeServe, func(r *ghttp.Request) {
  18. r.Response.CORSDefault()
  19. })
  20. group.Group("/captcha", func(group *ghttp.RouterGroup) {
  21. group.GET("/get", api.Captcha.Img)
  22. })
  23. })
  24. }