ORIONIS API REFERENCE

THE ORIONIS API

Build with clarity.

Explore the building blocks of an async-first Python framework. Every module, class, and method — connected, searchable, and ready to build with.

class documentation

class CORSMiddleware: (source)

Constructor: CORSMiddleware(config)

View In Hierarchy

Validate cross-origin requests and attach the required CORS headers.

Method __applyCredentials Write the Access-Control-Allow-Credentials header if needed.
Method __applyOrigin Write the Access-Control-Allow-Origin (and Vary) headers.
Method __init__ Initialize the middleware with the given CORS configuration.
Method __isAllowedOrigin Validate whether an origin is allowed.
Method __isPreflight Determine whether the request is a CORS preflight.
Method __mergeVary Append a directive to the Vary header without overwriting it.
Method after Apply CORS headers to actual (non-preflight) responses.
Method before Intercept preflight requests and return an early response.
Constant ALL_METHODS Methods allowed in CORS preflight responses when the wildcard is used.
Class Variable __slots__ Declare the instance attribute slots reserved by this class.
Instance Variable __allow_all_headers Headers.
Instance Variable __allow_all_methods Methods.
Instance Variable __allow_all_origins Origins.
Instance Variable __allow_credentials Credentials / Cache.
Instance Variable __allow_headers_value Serialized value of the Access-Control-Allow-Headers header.
Instance Variable __allow_methods_value Serialized value of the Access-Control-Allow-Methods header.
Instance Variable __allow_origins Origins permitted by the cross-origin request policy.
Instance Variable __expose_headers_value Serialized value of the Access-Control-Expose-Headers header.
Instance Variable __max_age_value Pre-render the max-age header value; None disables the header.
Instance Variable __origin_regex Compiled regular expression matching permitted request origins.
def __applyCredentials(self, response: Response): (source)

Write the Access-Control-Allow-Credentials header if needed.

Parameters
response:orionis.http.ResponseThe response object to modify.
Returns
NoneWrite the Access-Control-Allow-Credentials header if needed.
def __applyOrigin(self, response: Response, origin: str): (source)

Write the Access-Control-Allow-Origin (and Vary) headers.

Parameters
response:orionis.http.ResponseThe response object to modify.
origin:strThe Origin header value from the request.
Returns
NoneWrite the Access-Control-Allow-Origin (and Vary) headers.
def __init__(self, config: dict): (source)

Initialize the middleware with the given CORS configuration.

Parameters
config:dictA dictionary whose keys must match Cors fields.
Returns
NoneInitialize the middleware with the given CORS configuration.
def __isAllowedOrigin(self, origin: str) -> bool: (source)

Validate whether an origin is allowed.

Parameters
origin:strThe Origin header value from the request.
Returns
boolTrue when the origin is permitted, False otherwise.
def __isPreflight(self, method: str, headers: object) -> bool: (source)

Determine whether the request is a CORS preflight.

Parameters
method:strThe HTTP method of the incoming request.
headers:objectThe parsed request headers (supports in operator).
Returns
boolTrue for preflight requests (OPTIONS + ACRM header).
def __mergeVary(self, response: Response, value: str): (source)

Append a directive to the Vary header without overwriting it.

Parameters
response:orionis.http.ResponseThe response object to modify.
value:strThe directive to add (e.g. "origin").
Returns
NoneAppend a directive to the Vary header without overwriting it.
def after(self, adapter: TransportAdapter, response: Response) -> Response: (source)

Apply CORS headers to actual (non-preflight) responses.

Parameters
adapter:orionis.http.adapters.request.contracts.transport.TransportAdapterUnified transport abstraction for the current request.
response:orionis.http.ResponseThe response produced by the application.
Returns
orionis.http.ResponseThe same response object, enriched with CORS headers.
def before(self, adapter: TransportAdapter) -> Response | None: (source)

Intercept preflight requests and return an early response.

Parameters
adapter:orionis.http.adapters.request.contracts.transport.TransportAdapterUnified transport abstraction for the current request.
Returns
orionis.http.Response | NoneA 204 No Content preflight response, or None when the request is not a valid CORS preflight.
ALL_METHODS: str = (source)

Methods allowed in CORS preflight responses when the wildcard is used.

Value
'DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT, QUERY'
__slots__: tuple[str, ...] = (source)

Declare the instance attribute slots reserved by this class.

__allow_all_headers = (source)

Headers.

__allow_all_methods = (source)

Methods.

__allow_all_origins = (source)

Origins.

__allow_credentials = (source)

Credentials / Cache.

__allow_headers_value = (source)

Serialized value of the Access-Control-Allow-Headers header.

__allow_methods_value = (source)

Serialized value of the Access-Control-Allow-Methods header.

__allow_origins = (source)

Origins permitted by the cross-origin request policy.

__expose_headers_value = (source)

Serialized value of the Access-Control-Expose-Headers header.

__max_age_value: str | None = (source)

Pre-render the max-age header value; None disables the header.

__origin_regex: Pattern[str] | None = (source)

Compiled regular expression matching permitted request origins.