增加跨域处理的中间件

This commit is contained in:
2022-07-13 16:31:04 +08:00
parent 53b9196970
commit 846873e7cd
3 changed files with 409 additions and 0 deletions

View File

@ -0,0 +1,40 @@
// Package request_cors ...
//
// Description : request_cors ...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2022-07-13 16:27
package request_cors
import "net/http"
type cors struct {
allowAllOrigins bool
allowCredentials bool
allowOriginFunc func(string) bool
allowOrigins []string
normalHeaders http.Header
preflightHeaders http.Header
wildcardOrigins [][]string
}
var (
DefaultSchemas = []string{
"http://",
"https://",
}
ExtensionSchemas = []string{
"chrome-extension://",
"safari-extension://",
"moz-extension://",
"ms-browser-extension://",
}
FileSchemas = []string{
"file://",
}
WebSocketSchemas = []string{
"ws://",
"wss://",
}
)