cors

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

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

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

README

Go Report Card GoDoc

KrakenD CORS

A set of building blocks for instrumenting KrakenD gateways

Available flavours

  1. mux Mux based handlers
  2. gin Gin based handlers

Check the tests and the documentation for more details

Configuration

You need to add an ExtraConfig section to the configuration to enable the CORS middleware. At least one option should be defined.

  • allow_origins list of strings (you can also use a wildcard, leaving it empty allows all origins too)
  • allow_headers list of strings
  • allow_methods list of strings
  • expose_headers list of strings
  • allow_credentials bool
  • max_age duration (Ex: "12h", "5m", "3600s", ...)
Configuration Example
  "extra_config": {
    "github_com/devopsfaith/krakend-cors": {
      "allow_origins": [ "http://foobar.com" ],
      "allow_methods": [ "POST", "GET"],
      "max_age": "12h"
    }
  }

or leave the defaults (the defaults allows all origins):

"extra_config": {
  github_com/devopsfaith/krakend-metrics": {
    "allow_origins": []
  }
}

Documentation

Index

Constants

View Source
const Namespace = "github_com/devopsfaith/krakend-cors"

Namespace is the key to look for extra configuration details

Variables

This section is empty.

Functions

func ConfigGetter

func ConfigGetter(e config.ExtraConfig) interface{}

ConfigGetter implements the config.ConfigGetter interface. It parses the extra config an allowed origin must be defined, the rest of the options will use a default if not defined.

Types

type Config

type Config struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	ExposeHeaders    []string
	AllowCredentials bool
	MaxAge           time.Duration
}

Config holds the configuration of CORS

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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