[#217] Add errors for cors

Signed-off-by: Angira Kekteeva <kira@nspcc.ru>
This commit is contained in:
Angira Kekteeva 2021-10-08 16:58:21 +03:00 committed by Kirillov Denis
parent bbb6727054
commit 5b4b9df031
2 changed files with 23 additions and 3 deletions

View file

@ -262,13 +262,12 @@ func checkCORS(cors *CORSConfiguration) error {
for _, r := range cors.CORSRules {
for _, m := range r.AllowedMethods {
if _, ok := supportedMethods[m]; !ok {
return fmt.Errorf("unsupported HTTP method in CORS config %s", m)
return errors.GetAPIErrorWithError(errors.ErrCORSUnsupportedMethod, fmt.Errorf("unsupported method is %s", m))
}
}
for _, h := range r.ExposeHeaders {
if h == wildcard {
return fmt.Errorf("ExposeHeader \"*\" contains wildcard. We currently do not support wildcard " +
"for ExposeHeader")
return errors.GetAPIError(errors.ErrCORSWildcardExposeHeaders)
}
}
}