Gin
跨域处理¶
route := gin.Default()
route.Use(cors.New(cors.Config{
AllowOriginFunc: func(origin string) bool { return true },
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH"},
AllowHeaders: []string{"Origin", "Content-Length", "Content-Type"},
AllowCredentials: true,
MaxAge: 12 * time.Hour,
}))
staticFIle¶
route.StaticFile("/", `send.html`)//file
route.StaticFS("/static",http.Dir("static")) //dir
返回json¶
c.JSON(200, &CountryStatics)
本页面的全部内容在 CC BY-NC-SA 4.0 协议之条款下提供,附加条款亦可能应用。