DKube v1.0

This commit is contained in:
DingQz
2022-10-12 10:34:43 +08:00
parent 7f9aae166e
commit 10abbb0fb3
46 changed files with 3154 additions and 153 deletions

24
middle/cors.go Normal file
View File

@ -0,0 +1,24 @@
package middle
import (
"github.com/gin-gonic/gin"
"net/http"
)
func Cors() gin.HandlerFunc {
return func(c *gin.Context) {
method := c.Request.Method
c.Header("Content-Type", "application/json")
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Max-Age", "86400")
c.Header("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE, UPDATE")
c.Header("Access-Control-Allow-Headers", "X-Token, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Max")
c.Header("Access-Control-Allow-Credentials", "false")
if method == "OPTIONS" {
c.AbortWithStatus(http.StatusNoContent)
}
c.Next()
}
}