cors

package
v0.0.62 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type CORS added in v0.0.40

type CORS struct {
	Enable bool `protobuf:"varint,1,opt,name=enable,proto3" json:"enable,omitempty"`
	// returns Access-Control-Allow-Origin: * if false
	UseConditional bool `protobuf:"varint,2,opt,name=use_conditional,json=useConditional,proto3" json:"use_conditional,omitempty"`
	// allowed_origins is a list of origins a cross-domain request can be executed from.
	// If the special "*" value is present in the list, all origins will be allowed.
	// An origin may contain a wildcard (*) to replace 0 or more characters
	// (i.e.: http://*.domain.com). Usage of wildcards implies a small performance penalty.
	// Only one wildcard can be used per origin.
	// Default value is ["*"]
	// return Access-Control-Allow-Origin
	AllowedOrigins []string `protobuf:"bytes,3,rep,name=allowed_origins,json=allowedOrigins,proto3" json:"allowed_origins,omitempty"`
	// allowed_methods is a list of methods the client is allowed to use with
	// cross-domain requests. Default value is simple methods (HEAD, GET and POST).
	AllowedMethods []string `protobuf:"bytes,4,rep,name=allowed_methods,json=allowedMethods,proto3" json:"allowed_methods,omitempty"`
	// allowed_headers is list of non simple headers the client is allowed to use with
	// cross-domain requests.
	// If the special "*" value is present in the list, all headers will be allowed.
	// Default value is [] but "Origin" is always appended to the list.
	AllowedHeaders []string `protobuf:"bytes,5,rep,name=allowed_headers,json=allowedHeaders,proto3" json:"allowed_headers,omitempty"`
	// exposed_headers indicates which headers are safe to expose to the API of a CORS
	// API specification
	// return Access-Control-Expose-Headers
	ExposedHeaders []string `protobuf:"bytes,6,rep,name=exposed_headers,json=exposedHeaders,proto3" json:"exposed_headers,omitempty"`
	// allow_credentials indicates whether the request can include user credentials like
	// cookies, HTTP authentication or client side SSL certificates.
	// return Access-Control-Allow-Credentials
	AllowCredentials bool `protobuf:"varint,7,opt,name=allow_credentials,json=allowCredentials,proto3" json:"allow_credentials,omitempty"`
	// options_passthrough instructs preflight to let other potential next handlers to
	// process the OPTIONS method. Turn this on if your application handles OPTIONS.
	OptionsPassthrough bool `protobuf:"varint,8,opt,name=options_passthrough,json=optionsPassthrough,proto3" json:"options_passthrough,omitempty"`
	// max_age indicates how long the results of a preflight request
	// can be cached
	MaxAge *durationpb.Duration `protobuf:"bytes,9,opt,name=max_age,json=maxAge,proto3" json:"max_age,omitempty"`
	// debug flag adds additional output to debug server side CORS issues
	Debug bool `protobuf:"varint,10,opt,name=debug,proto3" json:"debug,omitempty"`
	// contains filtered or unexported fields
}

func (*CORS) Descriptor deprecated added in v0.0.40

func (*CORS) Descriptor() ([]byte, []int)

Deprecated: Use CORS.ProtoReflect.Descriptor instead.

func (*CORS) GetAllowCredentials added in v0.0.40

func (x *CORS) GetAllowCredentials() bool

func (*CORS) GetAllowedHeaders added in v0.0.40

func (x *CORS) GetAllowedHeaders() []string

func (*CORS) GetAllowedMethods added in v0.0.40

func (x *CORS) GetAllowedMethods() []string

func (*CORS) GetAllowedOrigins added in v0.0.40

func (x *CORS) GetAllowedOrigins() []string

func (*CORS) GetDebug added in v0.0.40

func (x *CORS) GetDebug() bool

func (*CORS) GetEnable added in v0.0.40

func (x *CORS) GetEnable() bool

func (*CORS) GetExposedHeaders added in v0.0.40

func (x *CORS) GetExposedHeaders() []string

func (*CORS) GetMaxAge added in v0.0.40

func (x *CORS) GetMaxAge() *durationpb.Duration

func (*CORS) GetOptionsPassthrough added in v0.0.40

func (x *CORS) GetOptionsPassthrough() bool

func (*CORS) GetUseConditional added in v0.0.40

func (x *CORS) GetUseConditional() bool

func (*CORS) ProtoMessage added in v0.0.40

func (*CORS) ProtoMessage()

func (*CORS) ProtoReflect added in v0.0.40

func (x *CORS) ProtoReflect() protoreflect.Message

func (*CORS) Reset added in v0.0.40

func (x *CORS) Reset()

func (*CORS) String added in v0.0.40

func (x *CORS) String() string

type CompletedConfig

type CompletedConfig struct {
	// contains filtered or unexported fields
}

func (CompletedConfig) New

func (c CompletedConfig) New() *cors.Cors

func (CompletedConfig) NewGinHandler added in v0.0.14

func (c CompletedConfig) NewGinHandler() gin.HandlerFunc

func (CompletedConfig) NewWrapper added in v0.0.14

func (c CompletedConfig) NewWrapper() func(http.Handler) http.Handler

func (CompletedConfig) Validate added in v0.0.44

func (c CompletedConfig) Validate() error

Validate checks Config and return a slice of found errs.

type Config

type Config struct {
	Proto     CORS
	Validator *validator.Validate
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Config

NewConfig returns a Config struct with the default values

func NewViperConfig added in v0.0.40

func NewViperConfig(v *viper.Viper, keys ...string) *Config

NewViperConfig returns a Config struct with the global viper instance key representing a sub tree of this instance. NewViperConfig is case-insensitive for a key.

func (*Config) Complete

func (c *Config) Complete() CompletedConfig

Complete fills in any fields not set that are required to have valid data and can be derived from other fields. If you're going to `ApplyOptions`, do that first. It's mutating the receiver.

Jump to

Keyboard shortcuts

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