mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Addressed PR feedback
This commit is contained in:
parent
26ab188922
commit
e6f24aa8b1
@ -120,7 +120,15 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
|
|||||||
return c.NoContent(http.StatusNoContent)
|
return c.NoContent(http.StatusNoContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.AllowOriginFunc == nil {
|
if config.AllowOriginFunc != nil {
|
||||||
|
allowed, err := config.AllowOriginFunc(origin)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if allowed {
|
||||||
|
allowOrigin = origin
|
||||||
|
}
|
||||||
|
} else {
|
||||||
// Check allowed origins
|
// Check allowed origins
|
||||||
for _, o := range config.AllowOrigins {
|
for _, o := range config.AllowOrigins {
|
||||||
if o == "*" && config.AllowCredentials {
|
if o == "*" && config.AllowCredentials {
|
||||||
@ -156,14 +164,6 @@ func CORSWithConfig(config CORSConfig) echo.MiddlewareFunc {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
allowed, err := config.AllowOriginFunc(origin)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if allowed {
|
|
||||||
allowOrigin = origin
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Origin not allowed
|
// Origin not allowed
|
||||||
|
Loading…
Reference in New Issue
Block a user