Ryan aed0f28f13
Migrate to svelte for frontend (#9)
* Svelte: WIP

* WIP

* WIP

* WIP

* WIP

* WIP

* Finished

* Remove redundant code

* Fix typo

* Re-add routes

* Form margin

* Mobile nicities

* Mobile changed

* Increase keepalvie

* Update Guild.svelte

* Update Whitelabel.svelte

* Whitelabel changes
2021-06-30 15:40:55 +01:00

25 lines
824 B
Go

package middleware
import (
"github.com/TicketsBot/GoPanel/config"
"github.com/gin-gonic/gin"
"net/http"
"strings"
)
func Cors(config config.Config) func(*gin.Context) {
methods := []string{http.MethodOptions, http.MethodGet, http.MethodPost, http.MethodPatch, http.MethodPut, http.MethodDelete}
headers := []string{"x-tickets", "Content-Type", "Authorization"}
return func(ctx *gin.Context) {
ctx.Header("Access-Control-Allow-Origin", config.Server.BaseUrl)
ctx.Header("Access-Control-Allow-Methods", strings.Join(methods, ", "))
ctx.Header("Access-Control-Allow-Headers", strings.Join(headers, ", "))
ctx.Header("Access-Control-Allow-Credentials", "true")
ctx.Header("Access-Control-Max-Age", "600")
if ctx.Request.Method == http.MethodOptions {
ctx.AbortWithStatus(http.StatusNoContent)
}
}
}