This repo's all responsibilities were migrated to github.com/istyle-inc/goacors.
a cors-header middleware for goa(https://github.com/goadesign/goa)
-
first, import this from glide, or
go get github.com/deadcheat/goacors
-
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 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.
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