@@ -35,34 +35,41 @@ CORSConfig struct {
35
35
36
36
// AllowOrigin defines a list of origins that may access the resource.
37
37
// Optional. Default value []string{"*"}.
38
- AllowOrigins []string ` json:"allow_origins"`
38
+ AllowOrigins []string ` yaml:"allow_origins"`
39
+
40
+ // AllowOriginFunc is a custom function to validate the origin. It takes the
41
+ // origin as an argument and returns true if allowed or false otherwise. If
42
+ // an error is returned, it is returned by the handler. If this option is
43
+ // set, AllowOrigins is ignored.
44
+ // Optional.
45
+ AllowOriginFunc func (origin string ) (bool , error ) ` yaml:"allow_origin_func"`
39
46
40
47
// AllowMethods defines a list methods allowed when accessing the resource.
41
48
// This is used in response to a preflight request.
42
49
// Optional. Default value DefaultCORSConfig.AllowMethods.
43
- AllowMethods []string ` json :"allow_methods"`
50
+ AllowMethods []string ` yaml :"allow_methods"`
44
51
45
52
// AllowHeaders defines a list of request headers that can be used when
46
- // making the actual request. This in response to a preflight request.
53
+ // making the actual request. This is in response to a preflight request.
47
54
// Optional. Default value []string{}.
48
- AllowHeaders []string ` json :"allow_headers"`
55
+ AllowHeaders []string ` yaml :"allow_headers"`
49
56
50
57
// AllowCredentials indicates whether or not the response to the request
51
58
// can be exposed when the credentials flag is true. When used as part of
52
59
// a response to a preflight request, this indicates whether or not the
53
60
// actual request can be made using credentials.
54
61
// Optional. Default value false.
55
- AllowCredentials bool ` json :"allow_credentials"`
62
+ AllowCredentials bool ` yaml :"allow_credentials"`
56
63
57
64
// ExposeHeaders defines a whitelist headers that clients are allowed to
58
65
// access.
59
66
// Optional. Default value []string{}.
60
- ExposeHeaders []string ` json :"expose_headers"`
67
+ ExposeHeaders []string ` yaml :"expose_headers"`
61
68
62
69
// MaxAge indicates how long (in seconds) the results of a preflight request
63
70
// can be cached.
64
71
// Optional. Default value 0.
65
- MaxAge int ` json :"max_age"`
72
+ MaxAge int ` yaml :"max_age"`
66
73
}
67
74
```
68
75
0 commit comments