Documentation
¶
Overview ¶
package rkmidcors provide cors related options
Index ¶
- type BeforeCtx
- type BootConfig
- type Option
- func ToOptions(config *BootConfig, entryName, entryType string) []Option
- func WithAllowCredentials(allow bool) Option
- func WithAllowHeaders(headers ...string) Option
- func WithAllowMethods(methods ...string) Option
- func WithAllowOrigins(origins ...string) Option
- func WithEntryNameAndType(entryName, entryType string) Option
- func WithExposeHeaders(headers ...string) Option
- func WithIgnorePrefix(paths ...string) Option
- func WithMaxAge(age int) Option
- func WithMockOptionSet(mock OptionSetInterface) Option
- type OptionSetInterface
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeforeCtx ¶
type BeforeCtx struct { Input struct { UrlPath string OriginHeader string IsPreflight bool AccessControlRequestHeaders string } Output struct { HeadersToReturn map[string]string HeaderVary []string Abort bool } }
BeforeCtx context for Before() function
func NewBeforeCtx ¶
func NewBeforeCtx() *BeforeCtx
NewBeforeCtx create new BeforeCtx with fields initialized
type BootConfig ¶
type BootConfig struct { Enabled bool `yaml:"enabled" json:"enabled"` AllowOrigins []string `yaml:"allowOrigins" json:"allowOrigins"` AllowCredentials bool `yaml:"allowCredentials" json:"allowCredentials"` AllowHeaders []string `yaml:"allowHeaders" json:"allowHeaders"` AllowMethods []string `yaml:"allowMethods" json:"allowMethods"` ExposeHeaders []string `yaml:"exposeHeaders" json:"exposeHeaders"` MaxAge int `yaml:"maxAge" json:"maxAge"` IgnorePrefix []string `yaml:"ignorePrefix" json:"ignorePrefix"` }
BootConfig for YAML
type Option ¶
type Option func(*optionSet)
Option
func ToOptions ¶
func ToOptions(config *BootConfig, entryName, entryType string) []Option
ToOptions convert BootConfig into Option list
func WithAllowCredentials ¶
WithAllowCredentials allow credentials or not
func WithAllowHeaders ¶
WithAllowHeaders provide allowed headers
func WithAllowMethods ¶
WithAllowMethods provide allowed http methods
func WithAllowOrigins ¶
WithAllowOrigins provide allowed origins.
func WithEntryNameAndType ¶
WithEntryNameAndType provide entry name and entry type.
func WithExposeHeaders ¶
WithExposeHeaders provide expose headers
func WithIgnorePrefix ¶
WithIgnorePrefix provide paths prefix that will ignore. Mainly used for swagger main page and RK TV entry.
func WithMockOptionSet ¶
func WithMockOptionSet(mock OptionSetInterface) Option
WithMockOptionSet provide mock OptionSetInterface
type OptionSetInterface ¶
type OptionSetInterface interface { GetEntryName() string GetEntryType() string Before(*BeforeCtx) BeforeCtx(*http.Request) *BeforeCtx }
OptionSetInterface mainly for testing purpose
func NewOptionSet ¶
func NewOptionSet(opts ...Option) OptionSetInterface
NewOptionSet Create new optionSet with options.
func NewOptionSetMock ¶
func NewOptionSetMock(before *BeforeCtx) OptionSetInterface
NewOptionSetMock for testing purpose