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.

module documentation

Undocumented

Function _middleware_key Return a stable ordering key for middleware supplied in sets.
Function flatten_middleware Flatten and validate middleware arguments into a plain list.
Function is_valid_handler Check whether the route action parser accepts a candidate.
Function normalize_path Normalise an HTTP route path to a canonical form.
Function normalize_request_path Normalise a request path for route resolution.
Function parse_action Parse and validate a route action into a normalised tuple.
Function strip_regex_anchors Remove start and end anchors from a regex pattern.
Constant _ACTION_LIST_LENGTH Undocumented
Constant _MULTI_SLASH_RE Undocumented
def _middleware_key(middleware: type[BaseMiddleware | WebSocketMiddleware]) -> tuple[str, str]: (source)

Return a stable ordering key for middleware supplied in sets.

Parameters
middleware:type[BaseMiddleware | WebSocketMiddleware]Middleware class to order consistently when using unordered containers.
Returns
tuple[str, str]The module name and qualified class name used as the sort key.
def flatten_middleware(*middleware: MiddlewareInput) -> list[type[BaseMiddleware | WebSocketMiddleware]]: (source)

Flatten and validate middleware arguments into a plain list.

Accepts middleware classes passed either individually or wrapped in a list, tuple, set or frozenset (one level of nesting), so all of these are equivalent:

flatten_middleware(A, B)
flatten_middleware([A, B])
flatten_middleware((A,), B)
Parameters
*middleware:type | list | tuple | set | frozensetMiddleware classes or containers of middleware classes.
Returns
list[type[BaseMiddleware | WebSocketMiddleware]]Flat list of validated middleware classes, in the order they were provided.
Raises
TypeErrorIf an entry is neither HTTP nor WebSocket middleware.
def is_valid_handler(action: object) -> bool: (source)

Check whether the route action parser accepts a candidate.

Notes

Does not instantiate controllers or invoke handlers. Controller attribute lookup may execute descriptors; exceptions other than TypeError and ValueError propagate. Importability and dependency resolution are checked later in the routing lifecycle.

Parameters
action:objectCandidate function, invokable controller class, or controller/method pair to validate using the same rules as parse_action.
Returns
boolTrue if parse_action accepts the candidate; False if it raises TypeError or ValueError for an unsupported or malformed action.
def normalize_path(path: str) -> str: (source)

Normalise an HTTP route path to a canonical form.

Rules applied in order:

  1. Strip leading/trailing whitespace.
  2. Collapse consecutive slashes (//, ///, …) into one.
  3. Ensure the path starts with exactly one /.
  4. Remove any trailing / (except for the root path /).
Parameters
path:strRaw route path supplied by the developer.
Returns
strNormalised path, e.g. '//users//me/' → '/users/me'.
def normalize_request_path(path: str) -> str: (source)

Normalise a request path for route resolution.

Parameters
path:strRaw request path from the HTTP layer.
Returns
strPath with a leading / and without trailing slashes on non-root paths.
def parse_action(action: object) -> tuple[Callable, None] | tuple[type, str]: (source)

Parse and validate a route action into a normalised tuple.

Supports three forms:

  1. Invokable controller — concrete class that defines __call__.
  2. Controller + method — two-element list or tuple with a concrete class [ControllerClass, 'method_name'].
  3. Python function — plain function or coroutine function, excluding lambdas. Callable instances, bound methods and builtins are unsupported.
Parameters
action:objectCandidate action to validate against the three forms described above.
Returns
tuple[Callable, None] | tuple[type, str]
Raises
TypeErrorIf a bare class does not define __call__, if list elements have wrong types, if a controller class is abstract in either form, or if action is none of the accepted forms.
ValueErrorIf the list does not have exactly two elements, or if the controller class does not expose the requested method.
def strip_regex_anchors(pattern: str) -> str: (source)

Remove start and end anchors from a regex pattern.

Parameters
pattern:strRegex pattern that may start with ^ and end with $.
Returns
strPattern without a leading ^ and trailing $.
_ACTION_LIST_LENGTH: int = (source)

Undocumented

Value
2
_MULTI_SLASH_RE: re.Pattern = (source)

Undocumented

Value
re.compile(r'/{2,}')