Routing configuration
proxyx.yaml file
The entire routing is configured within a single yaml file. It supports hinting if you use jsonschema.json from the root of this repository.
Fields documentation
- pydantic model proxyx.models.BaseModel
- pydantic model proxyx.models.MatchingRule
- field header_patterns: Dict[str, Any] = {}
If you need to route based on header value, put your matching rule here. It accepts regex and an asterix (
*) for catch-all.- Validated by
- field url_patterns: List[Union[str, Pattern]] = ['*']
A list of regex patterns for matching request urls. If one of the patterns is matching, this router will be used. The only non-regex special value allowed is an asterix (
*). If used, it will catch all incoming requests. Used by default, if no other value is provided. If multiple routers match the same request url, only the first one will be used.- Validated by
- validator initialize_header_patterns » header_patterns
Initializes header_patterns, from string to compiled Python regex pattern.
- Parameters
patterns – Dict of header name: header pattern as string.
- Returns
Dict of header name: header pattern as a compiled pattern.
- validator initialize_url_patterns » url_patterns
Initializes url_patterns, from string to compiled Python regex pattern.
- Parameters
patterns – List of patterns as strings.
- Returns
List of initialized patterns, compiled once.
- is_matching(request: Request) bool
Allows to determine whether the request url matches one of the router url patterns.
- Parameters
request – ASGI request
- pydantic model proxyx.models.Proxyx
Main object that holds all the information about all the routers.
It is used directly in the view.
- pydantic model proxyx.models.Router
A custom object that defines three steps:
matching criteria for incoming request,
how to validate the request,
where to pass it.
- field force_https: bool = True
Whether to always use https, even if http is provided from the downstream.
- field matching_rules: List[MatchingRule] [Required]
- field replace_target_host: str = None
Will replace the incoming request host with this one.
- field request_path_has_full_path: bool = True
Request expects one optional attribute. It might be the entire path www.example.com/resource, or just /resource.
- field required_headers: Dict[str, Pattern] = {}
For each key-value pair, where key is the header key and value is a regex pattern,validate whether the key exists. If so, validate if the value is matching the regex pattern.An asterix (
*) is a special value that will allow for any value.- Validated by
- validator initialize_required_headers » required_headers
Changes expected key value pairs into key value where value is a loaded regex pattern.
- Parameters
patterns – List of patterns as strings.
- Returns
List of initialized patterns, compiled once.
- async route(request)
Validates and forwards the request.
- Parameters
request – ASGI Request
- Returns
Upstream response.