cors

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package cors provides CORS configuration types and XML helpers.

Package cors provides CORS configuration types for buckets.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoCORSConfig is returned when no CORS configuration exists.
	ErrNoCORSConfig = errors.New("cors: bucket has no CORS configuration")
)

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 represents a bucket CORS configuration.

func NewConfig

func NewConfig(rules []Rule) Config

NewConfig creates a new CORS configuration with the given rules.

func ParseBucketCORSConfig added in v1.0.5

func ParseBucketCORSConfig(reader io.Reader) (Config, error)

ParseBucketCORSConfig parses a CORS configuration in XML from an io.Reader.

func (Config) ToXML

func (c Config) ToXML() ([]byte, error)

ToXML marshals the CORS configuration to XML.

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 represents a single CORS rule.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL