Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { XMLNS string `xml:"xmlns,attr,omitempty"` XMLName xml.Name `xml:"CORSConfiguration"` CORSRules []Rule `xml:"CORSRule"` }
Config is the container for a CORS configuration for a bucket.
func ParseBucketCorsConfig ¶
ParseBucketCorsConfig parses a CORS configuration in XML from an io.Reader.
func (*Config) Validate ¶
Validate checks the CORS configuration is valid. This has been implemented to return errors that can be transformed to match the S3 API externally, while being slightly more informative internally using wrapping. Validate copies S3 behavior, and validates one rule at a time, erroring on the first invalid one found.
type ErrAllowedHeaderWildcards ¶
type ErrAllowedHeaderWildcards struct {
Header string
}
ErrAllowedHeaderWildcards is returned when more than one wildcard is found in an AllowedHeader.
func (ErrAllowedHeaderWildcards) Error ¶
func (e ErrAllowedHeaderWildcards) Error() string
type ErrAllowedOriginWildcards ¶
type ErrAllowedOriginWildcards struct {
Origin string
}
ErrAllowedOriginWildcards is returned when more than one wildcard is found in an AllowedOrigin.
func (ErrAllowedOriginWildcards) Error ¶
func (e ErrAllowedOriginWildcards) Error() string
type ErrInvalidMethod ¶
type ErrInvalidMethod struct {
Method string
}
ErrInvalidMethod is returned when an unsupported HTTP method is found in a CORS config.
func (ErrInvalidMethod) Error ¶
func (e ErrInvalidMethod) Error() string
type ErrMalformedXML ¶
type ErrMalformedXML struct{}
ErrMalformedXML is returned when the XML provided is not well-formed
func (ErrMalformedXML) Error ¶
func (e ErrMalformedXML) Error() string
type ErrTooManyRules ¶
type ErrTooManyRules struct{}
ErrTooManyRules is returned when the number of CORS rules exceeds the allowed limit.
func (ErrTooManyRules) Error ¶
func (e ErrTooManyRules) Error() string
type Rule ¶
type Rule struct { AllowedHeader []string `xml:"AllowedHeader,omitempty"` AllowedMethod []string `xml:"AllowedMethod,omitempty"` AllowedOrigin []string `xml:"AllowedOrigin,omitempty"` ExposeHeader []string `xml:"ExposeHeader,omitempty"` ID string `xml:"ID,omitempty"` MaxAgeSeconds int `xml:"MaxAgeSeconds,omitempty"` }
Rule is a single rule in a CORS configuration.
func (*Rule) FilterAllowedHeaders ¶
FilterAllowedHeaders returns the headers that are allowed by the rule, and a boolean indicating if all headers are allowed.
func (*Rule) HasAllowedMethod ¶
HasAllowedMethod returns true if the given method is contained in the CORS rule.
func (*Rule) HasAllowedOrigin ¶
HasAllowedOrigin returns true if the given origin is allowed by the CORS rule