cors

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 1 Imported by: 0

README

cors使用方法

描述:跨域中间件

安装

go get gitee.com/sparrow614/sparrow_cloud_go

使用方法

import (
	...
	"gitee.com/sparrow614/sparrow_cloud_go/middleware/cors"
)

func main() {
    // 初始化iris app
    app := iris.New()
    // 配置跨域中间件,后面接口全部允许跨域
    app.Use(cors.Serve)
    // 接口允许options预检请求方法,该行必须配置
    app.AllowMethods(iris.MethodOptions)
    ...
    //
    app.Get("/test", processRequest)
    app.Listen("8081")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx iris.Context)

Types

This section is empty.

Jump to

Keyboard shortcuts

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