goweb_cors

package module
v0.0.0-...-bc76572 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 4 Imported by: 0

README

goweb-cors

Cross-origin_resource_sharing util for golang

What is CORS ?

CORS请求保护不当可导致敏感信息泄漏,因此应当严格设置Access-Control-Allow-Origin使用同源策略进行保护。

c := cors.New(cors.Options{
	AllowedOrigins:   []string{"http://qq.com", "https://qq.com"},
	AllowCredentials: true,
	Debug:            false,
})

// 引入中间件
handler = c.Handler(handler)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cors

func Cors(serverConfig *toml.Tree, EnvConfig string) *cors.Cors

* * @func Cors * @desc Cors middleware * @param config *toml.Tree ( get config from toml file, eg: config, err := toml.LoadFile(path) ) * @param Env string ( get env from toml file, eg: config = iris.TOML("./config/iris.toml") config.Get("env").(string) ) * @return cors.Options

func GetBool

func GetBool(tree *toml.Tree, key string, values ...bool) bool

func GetInt

func GetInt(tree *toml.Tree, key string, values ...int) int

func GetStringArray

func GetStringArray(tree *toml.Tree, key string, values ...[]string) []string

func GetTree

func GetTree(tree *toml.Tree, key string) *toml.Tree

func IsLocal

func IsLocal(Env string) bool

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL