a cors-header middleware for goa(https://github.com/goadesign/goa)
-
first, import this from glide, or
go get github.com/istyle-inc/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