add support for wildcard cors origin (#24)

This commit is contained in:
Matthew Baird 2017-06-27 21:27:08 -07:00 committed by Bo-Yi Wu
parent 5c9b3fa52c
commit f894742c19

View File

@ -69,8 +69,8 @@ func (c Config) Validate() error {
return errors.New("conflict settings: all origins disabled")
}
for _, origin := range c.AllowOrigins {
if !strings.HasPrefix(origin, "http://") && !strings.HasPrefix(origin, "https://") {
return errors.New("bad origin: origins must include http:// or https://")
if origin != "*" && !strings.HasPrefix(origin, "http://") && !strings.HasPrefix(origin, "https://") {
return errors.New("bad origin: origins must either be '*' or include http:// or https://")
}
}
return nil