Documentation
¶
Index ¶
- Variables
- type Cors
- func (*Cors) Descriptor() ([]byte, []int)deprecated
- func (x *Cors) GetAllowAnyHeader() bool
- func (x *Cors) GetAllowAnyMethod() bool
- func (x *Cors) GetAllowAnyOrigin() bool
- func (x *Cors) GetAllowBrowserExtensions() bool
- func (x *Cors) GetAllowCredentials() bool
- func (x *Cors) GetAllowCredentialsWithWildcard() bool
- func (x *Cors) GetAllowFiles() bool
- func (x *Cors) GetAllowOriginRegex() string
- func (x *Cors) GetAllowPrivateNetwork() bool
- func (x *Cors) GetAllowWebSockets() bool
- func (x *Cors) GetAllowWildcard() bool
- func (x *Cors) GetAllowedHeaders() []string
- func (x *Cors) GetAllowedMethods() []string
- func (x *Cors) GetAllowedOriginPatterns() []string
- func (x *Cors) GetAllowedOrigins() []string
- func (x *Cors) GetAllowedRequestHeadersPatterns() []string
- func (x *Cors) GetAllowedResponseHeaders() []string
- func (x *Cors) GetDebug() bool
- func (x *Cors) GetExposedHeaders() []string
- func (x *Cors) GetExposedStatusCodes() []int32
- func (x *Cors) GetMaxAge() int64
- func (x *Cors) GetMaxAgeHeader() string
- func (x *Cors) GetOptionsPassthrough() bool
- func (x *Cors) GetOptionsSuccessStatus() int32
- func (x *Cors) GetPreflightContinue() bool
- func (*Cors) ProtoMessage()
- func (x *Cors) ProtoReflect() protoreflect.Message
- func (x *Cors) Reset()
- func (x *Cors) String() string
- func (m *Cors) Validate() error
- func (m *Cors) ValidateAll() error
- type CorsMultiError
- type CorsValidationError
Constants ¶
This section is empty.
Variables ¶
var File_runtime_middleware_cors_v1_cors_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Cors ¶
type Cors struct {
// Enable debug logging for CORS processing
Debug bool `protobuf:"varint,1,opt,name=debug,proto3" json:"debug,omitempty"`
// When true, allows any origin (equivalent to allowed_origins = ["*"]).
// Security Note: Cannot be used with allow_credentials = true.
AllowAnyOrigin bool `protobuf:"varint,2,opt,name=allow_any_origin,proto3" json:"allow_any_origin,omitempty"`
// List of allowed origins (e.g., https://example.com).
// Use "*" to allow all origins (not recommended for production).
AllowedOrigins []string `protobuf:"bytes,3,rep,name=allowed_origins,proto3" json:"allowed_origins,omitempty"`
// List of origin patterns that are allowed to make requests.
// Supports wildcards (*) for subdomains (e.g., https://*.example.com).
// Example: ["https://*.example.com", "http://localhost:*"]
AllowedOriginPatterns []string `protobuf:"bytes,4,rep,name=allowed_origin_patterns,proto3" json:"allowed_origin_patterns,omitempty"`
// Use regular expression to match allowed origins
// Example: ".*\\.example\\.com$"
AllowOriginRegex string `protobuf:"bytes,5,opt,name=allow_origin_regex,proto3" json:"allow_origin_regex,omitempty"`
// Allow wildcard (*) in allowed_origins (e.g., "*.example.com")
AllowWildcard bool `protobuf:"varint,6,opt,name=allow_wildcard,proto3" json:"allow_wildcard,omitempty"`
// Allow credentials with wildcard origin (not recommended for security reasons)
AllowCredentialsWithWildcard bool `protobuf:"varint,7,opt,name=allow_credentials_with_wildcard,proto3" json:"allow_credentials_with_wildcard,omitempty"`
// List of allowed HTTP methods (e.g., GET, POST, PUT, DELETE, OPTIONS)
AllowedMethods []string `protobuf:"bytes,9,rep,name=allowed_methods,proto3" json:"allowed_methods,omitempty"`
// When true, allows any HTTP method in the Access-Control-Request-Method header.
// If false, only methods listed in allowed_methods are allowed.
AllowAnyMethod bool `protobuf:"varint,10,opt,name=allow_any_method,proto3" json:"allow_any_method,omitempty"`
// List of allowed HTTP headers in cross-origin requests
AllowedHeaders []string `protobuf:"bytes,11,rep,name=allowed_headers,proto3" json:"allowed_headers,omitempty"`
// When true, allows any header in the Access-Control-Request-Headers header.
// If false, only headers listed in allowed_headers are allowed.
AllowAnyHeader bool `protobuf:"varint,12,opt,name=allow_any_header,proto3" json:"allow_any_header,omitempty"`
// List of headers that can be exposed to the browser in the response
ExposedHeaders []string `protobuf:"bytes,13,rep,name=exposed_headers,proto3" json:"exposed_headers,omitempty"`
// List of allowed request header patterns (supports wildcards)
AllowedRequestHeadersPatterns []string `protobuf:"bytes,14,rep,name=allowed_request_headers_patterns,proto3" json:"allowed_request_headers_patterns,omitempty"`
// Maximum age (in seconds) to cache preflight requests
MaxAge int64 `protobuf:"varint,19,opt,name=max_age,proto3" json:"max_age,omitempty"`
// Custom header name for Max-Age (default: "Access-Control-Max-Age")
MaxAgeHeader string `protobuf:"bytes,20,opt,name=max_age_header,proto3" json:"max_age_header,omitempty"`
// When true, passes preflight requests to the next handler
PreflightContinue bool `protobuf:"varint,21,opt,name=preflight_continue,proto3" json:"preflight_continue,omitempty"`
// When true, passes OPTIONS requests to the next handler
OptionsPassthrough bool `protobuf:"varint,22,opt,name=options_passthrough,proto3" json:"options_passthrough,omitempty"`
// Status code to return for successful OPTIONS requests
OptionsSuccessStatus int32 `protobuf:"varint,23,opt,name=options_success_status,proto3" json:"options_success_status,omitempty"`
// Indicates whether the request can include user credentials (cookies, HTTP authentication).
// Security Note: Cannot be used with wildcard origins ("*") or allow_any_origin = true.
AllowCredentials bool `protobuf:"varint,29,opt,name=allow_credentials,proto3" json:"allow_credentials,omitempty"`
// List of HTTP status codes that should be exposed to the CORS client
ExposedStatusCodes []int32 `protobuf:"varint,30,rep,packed,name=exposed_status_codes,proto3" json:"exposed_status_codes,omitempty"`
// List of response headers that can be exposed to the client
AllowedResponseHeaders []string `protobuf:"bytes,31,rep,name=allowed_response_headers,proto3" json:"allowed_response_headers,omitempty"`
// Allow browser extension schemes (chrome-extension://, moz-extension://, etc.)
AllowBrowserExtensions bool `protobuf:"varint,32,opt,name=allow_browser_extensions,proto3" json:"allow_browser_extensions,omitempty"`
// Allow WebSocket connections
AllowWebSockets bool `protobuf:"varint,33,opt,name=allow_web_sockets,proto3" json:"allow_web_sockets,omitempty"`
// Allow requests from private network addresses (127.0.0.1, [::1], localhost)
AllowPrivateNetwork bool `protobuf:"varint,34,opt,name=allow_private_network,proto3" json:"allow_private_network,omitempty"`
// Allow file:// schema (use with caution, not recommended for production)
AllowFiles bool `protobuf:"varint,35,opt,name=allow_files,proto3" json:"allow_files,omitempty"`
// contains filtered or unexported fields
}
CORS configuration for cross-origin resource sharing
func (*Cors) Descriptor
deprecated
func (*Cors) GetAllowAnyHeader ¶
func (*Cors) GetAllowAnyMethod ¶
func (*Cors) GetAllowAnyOrigin ¶
func (*Cors) GetAllowBrowserExtensions ¶
func (*Cors) GetAllowCredentials ¶
func (*Cors) GetAllowCredentialsWithWildcard ¶
func (*Cors) GetAllowFiles ¶
func (*Cors) GetAllowOriginRegex ¶
func (*Cors) GetAllowPrivateNetwork ¶
func (*Cors) GetAllowWebSockets ¶
func (*Cors) GetAllowWildcard ¶
func (*Cors) GetAllowedHeaders ¶
func (*Cors) GetAllowedMethods ¶
func (*Cors) GetAllowedOriginPatterns ¶
func (*Cors) GetAllowedOrigins ¶
func (*Cors) GetAllowedRequestHeadersPatterns ¶
func (*Cors) GetAllowedResponseHeaders ¶
func (*Cors) GetExposedHeaders ¶
func (*Cors) GetExposedStatusCodes ¶
func (*Cors) GetMaxAgeHeader ¶
func (*Cors) GetOptionsPassthrough ¶
func (*Cors) GetOptionsSuccessStatus ¶
func (*Cors) GetPreflightContinue ¶
func (*Cors) ProtoMessage ¶
func (*Cors) ProtoMessage()
func (*Cors) ProtoReflect ¶
func (x *Cors) ProtoReflect() protoreflect.Message
func (*Cors) Validate ¶
Validate checks the field values on Cors with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Cors) ValidateAll ¶
ValidateAll checks the field values on Cors with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in CorsMultiError, or nil if none found.
type CorsMultiError ¶
type CorsMultiError []error
CorsMultiError is an error wrapping multiple validation errors returned by Cors.ValidateAll() if the designated constraints aren't met.
func (CorsMultiError) AllErrors ¶
func (m CorsMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (CorsMultiError) Error ¶
func (m CorsMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type CorsValidationError ¶
type CorsValidationError struct {
// contains filtered or unexported fields
}
CorsValidationError is the validation error returned by Cors.Validate if the designated constraints aren't met.
func (CorsValidationError) Cause ¶
func (e CorsValidationError) Cause() error
Cause function returns cause value.
func (CorsValidationError) Error ¶
func (e CorsValidationError) Error() string
Error satisfies the builtin error interface
func (CorsValidationError) ErrorName ¶
func (e CorsValidationError) ErrorName() string
ErrorName returns error name.
func (CorsValidationError) Field ¶
func (e CorsValidationError) Field() string
Field function returns field value.
func (CorsValidationError) Key ¶
func (e CorsValidationError) Key() bool
Key function returns key value.
func (CorsValidationError) Reason ¶
func (e CorsValidationError) Reason() string
Reason function returns reason value.