cors

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

README

Cros

介绍

aurora 跨域中间件处理(跨域中间件仅在全局中间件中可用) 使用示例:

package main

import (
	"gitee.com/aurora-engine/aurora"
	"gitee.com/aurora-engine/cros"
	"net/http"
)

func main() {
	// 创建跨域实例
	cross := new(cros.Cors)
	// 添加跨域路径
	cross.Domain(http.MethodGet, "/*")
	//使用跨域中间件
	a.Use(cross.Cors())
}

上述例子配置了一个,GET 的通用跨域。

Documentation

Index

Constants

View Source
const (
	AccessControlAllowOrigin      = "Access-Control-Allow-Origin"
	AccessControlAllowMethods     = "Access-Control-Allow-Methods"
	AccessControlAllowHeaders     = "Access-Control-Allow-Headers"
	AccessControlExposeHeaders    = "Access-Control-Expose-Headers"
	AccessControlAllowCredentials = "Access-Control-Allow-Credentials"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Cors

type Cors struct {
	Method           map[string][]string //运行跨域的 api
	Host             map[string][]string //允许跨域的主机
	AllowOrigin      []string
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials []string
	ExposeHeaders    []string
}

func New

func New() *Cors

func (*Cors) Cors

func (c *Cors) Cors() aurora.Middleware

func (*Cors) Domain

func (c *Cors) Domain(method string, url ...string)

Domain 添加跨域路径

func (*Cors) Origin

func (c *Cors) Origin(host string, method ...string)

Origin 配置可跨域主机

Jump to

Keyboard shortcuts

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