|
@@ -5,9 +5,19 @@ import (
|
|
|
"nodeMonitor/internal/controller"
|
|
|
)
|
|
|
|
|
|
+func MiddlewareCORS(r *ghttp.Request) {
|
|
|
+
|
|
|
+ corsOptions := r.Response.DefaultCORSOptions()
|
|
|
+ //corsOptions.AllowDomain = []string{"goframe.org", "baidu.com"}
|
|
|
+ r.Response.CORS(corsOptions)
|
|
|
+
|
|
|
+ r.Response.CORSDefault()
|
|
|
+
|
|
|
+ r.Middleware.Next()
|
|
|
+}
|
|
|
func BindController(group *ghttp.RouterGroup) {
|
|
|
group.Group("/api/v1", func(group *ghttp.RouterGroup) {
|
|
|
- group.Middleware(ghttp.MiddlewareHandlerResponse)
|
|
|
+ group.Middleware(ghttp.MiddlewareHandlerResponse, MiddlewareCORS)
|
|
|
//group.Middleware(middleware.Middleware().CORS)
|
|
|
//group.Middleware(ghttp.MiddlewareCORS())
|
|
|
NodeRouter(group)
|