caddy_cors

package module
v0.0.0-...-4b03f0f Latest Latest
Warning

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

Go to latest
Published: May 14, 2023 License: MIT Imports: 10 Imported by: 0

README

Caddy CORS Module

Caddy CORS is built to allow easy control over cross origin resource sharing from your Caddy configuration. It based off of the cors module created by captncraig.

Directive Syntax
cors [<matcher>] [allowed_origins: []string] {
  override_existing_cors: bool
  allowed_methods:        []string
  allow_credentials:      bool
  max_age:                int
  allowed_headers:        []string
  exposed_headers:        []string
}
Defaults

These are the default values of the Cors directive if left unset.

  • path: "/"
  • allowed_origins: "*"
  • override_existing_cors: false
  • allowed_methods: "GET", "POST", "PUT", "DELETE", "PATCH", "OPTIONS"
  • allow_credentials: false
  • max_age: 5 seconds
  • allowed_headers: empty
  • exposed_headers: empty

How to install

Install instructions here

How to use

Usage instructions here

Example Caddyfile

 Example caddyfile here

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cors

type Cors struct {
	// Directive Options
	AllowedOrigins       []string `json:"allowed_origins,omitempty"`
	OverrideExistingCors bool     `json:"override_existing_cors,omitempty"`
	AllowedMethods       []string `json:"allowed_methods,omitempty"`
	AllowCredentials     bool     `json:"allow_credentials,omitempty"`
	MaxAge               int      `json:"max_age,omitempty"`
	AllowedHeaders       []string `json:"allowed_headers,omitempty"`
	ExposedHeaders       []string `json:"exposed_headers,omitempty"`
	// contains filtered or unexported fields
}

Define the Cors middleware config

func (Cors) CaddyModule

func (Cors) CaddyModule() caddy.ModuleInfo

func (*Cors) Provision

func (c *Cors) Provision(ctx caddy.Context) error

Setup the Cors middleware

func (Cors) ServeHTTP

func (c Cors) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

Process the HTTP request adding our CORS headers

func (*Cors) UnmarshalCaddyfile

func (c *Cors) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

func (*Cors) Validate

func (c *Cors) Validate() error

Validate the Cors middleware config

Jump to

Keyboard shortcuts

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