Этот коммит содержится в:
Chris
2017-11-22 15:58:03 -06:00
коммит произвёл Christopher Speller
родитель 77a1dc1f2f
Коммит 1ccf093803
4 изменённых файлов: 17 добавлений и 18 удалений

Просмотреть файл

@@ -58,8 +58,8 @@ type CorsWrapper struct {
}
func (cw *CorsWrapper) ServeHTTP(w http.ResponseWriter, r *http.Request) {
if len(*cw.config().ServiceSettings.AllowCorsFrom) > 0 {
if utils.OriginChecker(r) {
if allowed := *cw.config().ServiceSettings.AllowCorsFrom; allowed != "" {
if utils.CheckOrigin(r, allowed) {
w.Header().Set("Access-Control-Allow-Origin", r.Header.Get("Origin"))
if r.Method == "OPTIONS" {
@@ -252,6 +252,13 @@ func (a *App) StopServer() {
}
}
func (a *App) OriginChecker() func(*http.Request) bool {
if allowed := *a.Config().ServiceSettings.AllowCorsFrom; allowed != "" {
return utils.OriginChecker(allowed)
}
return nil
}
// This is required to re-use the underlying connection and not take up file descriptors
func consumeAndClose(r *http.Response) {
if r.Body != nil {