[deprecated]This repo's all responsibilities were migrated to https://github.com/istyle-inc/goacors
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore
.travis.yml
README.md
cors.go
cors_intermediate_test.go
cors_test.go
glide.lock
glide.yaml
go.mod
go.sum
matcher.go
middleware_test.go
skipper.go
values.go

README.md

IMPORTANT - THIS REPO IS DEPRECATED.

This repo's all responsibilities were migrated to github.com/istyle-inc/goacors.

Build Status Coverage Status GoDoc

goacors

a cors-header middleware for goa(https://github.com/goadesign/goa)

how to use

  1. first, import this from glide, or go get github.com/deadcheat/goacors

  2. write your main.go generated automatically from goagen.

    service.Use(goacors.WithConfig(service, &goacors.DefaultGoaCORSConfig))
    
     or
    
    service.Use(goacors.WithConfig(service, &goacors.GoaCORSConfig{
    	AllowOrigins: []string{"http://example.com"},
    	AllowMethods: []string{goacors.GET},
    }))
    

Intermediate Match Mode

Intermediate Match Mode is using match logic allow wildcard in host, like *.example.com.

NOTIFY

Note that using wild card is not correct for specification of CORS.
And this mode is not recommended for production use.
I implemented this for only testing.

how to use Intermediate Match Mode

To use this mode, you can use goacors.WithConfig like below,

service.Use(goacors.WithConfig(service, &goacors.GoaCORSConfig{
	AllowOrigins:     []string{"http://example.com"},
	AllowMethods:     []string{goacors.GET},
	DomainStrategy:   goacors.AllowIntermediateMatch,
}))

DomainStrategy option is added for this. default is goacors.AllowStrict and you need to change this to goacors.AllowIntermediateMatch