|
|
@ -12,6 +12,7 @@ import ( |
|
|
|
|
|
|
|
|
func main() { |
|
|
func main() { |
|
|
r := gin.Default() |
|
|
r := gin.Default() |
|
|
|
|
|
r.Use(Cors()) |
|
|
r.POST("/sql", func(c *gin.Context) { |
|
|
r.POST("/sql", func(c *gin.Context) { |
|
|
var req struct { |
|
|
var req struct { |
|
|
Content string `json:"content"` |
|
|
Content string `json:"content"` |
|
|
@ -32,15 +33,14 @@ func main() { |
|
|
c.String(http.StatusOK, string(res)) |
|
|
c.String(http.StatusOK, string(res)) |
|
|
}) |
|
|
}) |
|
|
r.StaticFS("/", http.FS(web.Static)) |
|
|
r.StaticFS("/", http.FS(web.Static)) |
|
|
r.Use(Cors()) |
|
|
|
|
|
r.Run(":8000") |
|
|
r.Run(":8000") |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func Cors() gin.HandlerFunc { |
|
|
func Cors() gin.HandlerFunc { |
|
|
return cors.New(cors.Config{ |
|
|
return cors.New(cors.Config{ |
|
|
AllowOrigins: []string{"*"}, |
|
|
|
|
|
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "PATCH"}, |
|
|
|
|
|
|
|
|
AllowAllOrigins: true, |
|
|
AllowCredentials: true, |
|
|
AllowCredentials: true, |
|
|
|
|
|
AllowHeaders: []string{"*"}, |
|
|
MaxAge: time.Second * time.Duration(7200), |
|
|
MaxAge: time.Second * time.Duration(7200), |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |