cors

package
v6.7.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 6 Imported by: 1

Documentation

Overview

Package cors sets the appropriate CORS(https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) response headers, and lets you customize. Following customizations are allowed:

  • provide a list of allowed domains
  • provide a list of headers
  • set the max-age of CORS headers

The list of allowed methods are

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddOptionsHandlers

func AddOptionsHandlers(routes []*webgo.Route) []*webgo.Route

AddOptionsHandlers appends OPTIONS handler for all the routes The response body would be empty for all the new handlers added

func CORS

func CORS(cfg *Config) webgo.Middleware

CORS is a single CORS middleware which can be applied to the whole app at once

func Middleware

func Middleware(allowedOriginRegex []regexp.Regexp, corsTimeout, allowedMethods, allowedHeaders string) webgo.Middleware

Middleware can be used as well, it lets the user use this middleware without webgo

Types

type Config

type Config struct {
	TimeoutSecs    int
	Routes         []*webgo.Route
	AllowedOrigins []string
	AllowedHeaders []string
}

Config holds all the configurations which is available for customizing this middleware

Jump to

Keyboard shortcuts

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