proxy.py/proxy/plugin/reverse_proxy.py

77 lines
2.6 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
"""
proxy.py
~~~~~~~~
Fast, Lightweight, Pluggable, TLS interception capable proxy server focused on
Network monitoring, controls & Application development, testing, debugging.
:copyright: (c) 2013-present by Abhinav Singh and contributors.
:license: BSD, see LICENSE for more details.
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
.. spelling::
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
Lua
"""
import re
from typing import TYPE_CHECKING, List, Tuple, Union
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
from ..http import Url
from ..http.parser import HttpParser
from ..http.server import ReverseProxyBasePlugin
from ..common.types import RePattern
from ..http.exception.base import HttpProtocolException
if TYPE_CHECKING:
from ..core.connection import TcpServerConnection
class ReverseProxyPlugin(ReverseProxyBasePlugin):
"""This example plugin is equivalent to following Nginx configuration::
2021-11-16 23:34:29 +00:00
```text
location /get {
proxy_pass http://httpbin.org/get
}
2021-11-16 23:34:29 +00:00
```
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
Plugin also demonstrates how to write "Python" equivalent for any
"Nginx Lua" based configuration i.e. your plugin code will have
full control over what do after one of your route has matched.
"""
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
def routes(self) -> List[Union[str, Tuple[str, List[bytes]]]]:
return [
# A static route
(
r'/get$',
Update project test dependencies to ensure green workflow (#1371) * Use www.google.com for http2 tests * Update README.md Add missing tutorial's link (cherry picked from commit e459f932cdb54c37ac6343470eed8581396b642b) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * System packages for readthedocs * Pin pyyaml, see https://github.com/yaml/pyyaml/issues/724\#issuecomment-1638587228 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ignore flake8 S507 * precommit `pyyaml==5.3.1` * follow https://github.com/yaml/pyyaml/issues/724 * pin to essentials_openapi==0.1.4 for blacksheep * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove blacksheep dep * remove system_packages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check if tox upgrade helps with `ERROR: FAIL could not package project ` tox related issues * Fix links * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use `importlib.metadata` instead of `pkg_resources` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Just remove link from plugin docstring for now * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pin `sphinxcontrib-applehelp==1.0.2` which is breaking spellcheck * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Pin `sphinxcontrib-*` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pin `towncrier` too * add kwargs as a spelling * `_get_dist` backward compatible with 3.6 * Use `httpbingo.org` instead of `httpbin.org` in tests making network requests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use `httpbingo` for reverse proxy plugin too which is tested in workflows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * `importlib-metadata; python_version <= 3.7` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Integration test changes due to usage of httpbingo instead of httpbin * `importlib-metadata; python_version <= 3.7` moved to build essentials and bypass reverse proxy integration test result verification for now * Filter and ignore `DeprecationWarning` to make it work on 3.7 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * with deprecation ignore we dont need `importlib-metadata` --------- Co-authored-by: Wermeille Bastien <bastien.wermeille@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-11 07:34:10 +00:00
[b'http://httpbingo.org/get', b'https://httpbingo.org/get'],
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
),
# A dynamic route to catch requests on "/get/<int>""
# See "handle_route" method below for what we do when
# this pattern matches.
r'/get/(\d+)$',
]
def handle_route(
self,
request: HttpParser,
pattern: RePattern,
) -> Union[memoryview, Url, 'TcpServerConnection']:
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
"""For our example dynamic route, we want to simply convert
any incoming request to "/get/1" into "/get?id=1" when serving from upstream.
"""
Update project test dependencies to ensure green workflow (#1371) * Use www.google.com for http2 tests * Update README.md Add missing tutorial's link (cherry picked from commit e459f932cdb54c37ac6343470eed8581396b642b) * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * System packages for readthedocs * Pin pyyaml, see https://github.com/yaml/pyyaml/issues/724\#issuecomment-1638587228 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Ignore flake8 S507 * precommit `pyyaml==5.3.1` * follow https://github.com/yaml/pyyaml/issues/724 * pin to essentials_openapi==0.1.4 for blacksheep * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Remove blacksheep dep * remove system_packages * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Check if tox upgrade helps with `ERROR: FAIL could not package project ` tox related issues * Fix links * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use `importlib.metadata` instead of `pkg_resources` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Just remove link from plugin docstring for now * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pin `sphinxcontrib-applehelp==1.0.2` which is breaking spellcheck * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Pin `sphinxcontrib-*` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * pin `towncrier` too * add kwargs as a spelling * `_get_dist` backward compatible with 3.6 * Use `httpbingo.org` instead of `httpbin.org` in tests making network requests * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Use `httpbingo` for reverse proxy plugin too which is tested in workflows * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * `importlib-metadata; python_version <= 3.7` * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Integration test changes due to usage of httpbingo instead of httpbin * `importlib-metadata; python_version <= 3.7` moved to build essentials and bypass reverse proxy integration test result verification for now * Filter and ignore `DeprecationWarning` to make it work on 3.7 * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * with deprecation ignore we dont need `importlib-metadata` --------- Co-authored-by: Wermeille Bastien <bastien.wermeille@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-04-11 07:34:10 +00:00
choice: Url = Url.from_bytes(b'http://httpbingo.org/get')
[v2.4.3] Support for dynamic reverse proxy routes (#1188) * Merge pull request #1162 from abhinavsingh/master v2.4.2 (#1158) * pip prod(deps): bump blacksheep from 1.2.2 to 1.2.7 (#1161) Bumps [blacksheep](https://github.com/Neoteroi/BlackSheep) from 1.2.2 to 1.2.7. - [Release notes](https://github.com/Neoteroi/BlackSheep/releases) - [Changelog](https://github.com/Neoteroi/BlackSheep/blob/main/CHANGELOG.md) - [Commits](https://github.com/Neoteroi/BlackSheep/compare/v1.2.2...v1.2.7) --- updated-dependencies: - dependency-name: blacksheep dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump fregante/setup-git-user from 1.0.1 to 1.1.0 (#1160) Bumps [fregante/setup-git-user](https://github.com/fregante/setup-git-user) from 1.0.1 to 1.1.0. - [Release notes](https://github.com/fregante/setup-git-user/releases) - [Commits](https://github.com/fregante/setup-git-user/compare/v1.0.1...v1.1.0) --- updated-dependencies: - dependency-name: fregante/setup-git-user dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ts-node from 10.7.0 to 10.8.0 in /dashboard (#1159) Bumps [ts-node](https://github.com/TypeStrong/ts-node) from 10.7.0 to 10.8.0. - [Release notes](https://github.com/TypeStrong/ts-node/releases) - [Commits](https://github.com/TypeStrong/ts-node/compare/v10.7.0...v10.8.0) --- updated-dependencies: - dependency-name: ts-node dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * npm: bump ws from 8.5.0 to 8.6.0 in /dashboard (#1165) Bumps [ws](https://github.com/websockets/ws) from 8.5.0 to 8.6.0. - [Release notes](https://github.com/websockets/ws/releases) - [Commits](https://github.com/websockets/ws/compare/8.5.0...8.6.0) --- updated-dependencies: - dependency-name: ws dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * Delete FUNDING.yml * pip prod(deps): bump pytest from 6.2.5 to 7.0.1 (#1164) Bumps [pytest](https://github.com/pytest-dev/pytest) from 6.2.5 to 7.0.1. - [Release notes](https://github.com/pytest-dev/pytest/releases) - [Changelog](https://github.com/pytest-dev/pytest/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest/compare/6.2.5...7.0.1) --- updated-dependencies: - dependency-name: pytest dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Abhinav Singh <126065+abhinavsingh@users.noreply.github.com> * pip prod(deps): bump rope from 0.22.0 to 1.1.1 (#1167) Bumps [rope](https://github.com/python-rope/rope) from 0.22.0 to 1.1.1. - [Release notes](https://github.com/python-rope/rope/releases) - [Changelog](https://github.com/python-rope/rope/blob/master/CHANGELOG.md) - [Commits](https://github.com/python-rope/rope/compare/0.22.0...1.1.1) --- updated-dependencies: - dependency-name: rope dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump starlette from 0.17.1 to 0.19.1 (#1168) Bumps [starlette](https://github.com/encode/starlette) from 0.17.1 to 0.19.1. - [Release notes](https://github.com/encode/starlette/releases) - [Changelog](https://github.com/encode/starlette/blob/master/docs/release-notes.md) - [Commits](https://github.com/encode/starlette/compare/0.17.1...0.19.1) --- updated-dependencies: - dependency-name: starlette dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.940 to 0.960 (#1170) Bumps [mypy](https://github.com/python/mypy) from 0.940 to 0.960. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.940...v0.960) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Create FUNDING.yml * Address yaml lint * Bump actions/cache from 3.0.2 to 3.0.4 (#1185) Bumps [actions/cache](https://github.com/actions/cache) from 3.0.2 to 3.0.4. - [Release notes](https://github.com/actions/cache/releases) - [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md) - [Commits](https://github.com/actions/cache/compare/v3.0.2...v3.0.4) --- updated-dependencies: - dependency-name: actions/cache dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump actions/setup-python from 3 to 4 (#1186) Bumps [actions/setup-python](https://github.com/actions/setup-python) from 3 to 4. - [Release notes](https://github.com/actions/setup-python/releases) - [Commits](https://github.com/actions/setup-python/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-python dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump py-spy from 0.3.11 to 0.3.12 (#1174) Bumps [py-spy](https://github.com/benfred/py-spy) from 0.3.11 to 0.3.12. - [Release notes](https://github.com/benfred/py-spy/releases) - [Changelog](https://github.com/benfred/py-spy/blob/master/CHANGELOG.md) - [Commits](https://github.com/benfred/py-spy/compare/v0.3.11...v0.3.12) --- updated-dependencies: - dependency-name: py-spy dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * pip prod(deps): bump mypy from 0.960 to 0.961 (#1187) Bumps [mypy](https://github.com/python/mypy) from 0.960 to 0.961. - [Release notes](https://github.com/python/mypy/releases) - [Commits](https://github.com/python/mypy/compare/v0.960...v0.961) --- updated-dependencies: - dependency-name: mypy dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Add support for dynamic reverse proxy routing (#1180) * Add support for dynamic reverse proxy routing. Plugins must implement the `handle_route(self, request, pattern) -> Url` method from the base class to provide a choice of upstream url to serve. This work is backward compatible a.k.a. Old style static route patterns with hardcoded upstream urls will continue to work as-is. See `ReverseProxyBasePlugin` documentation for more details. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Address type issues * Fix spellcheck * Attempt to solve type errors * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Py3.8 also doesnt allow subscriptable pattern type * Remove debug print Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-06-11 17:26:01 +00:00
assert request.path
result = re.search(pattern, request.path.decode())
if not result or len(result.groups()) != 1:
raise HttpProtocolException('Invalid request')
assert choice.remainder == b'/get'
# NOTE: Internally, reverse proxy core replaces
# original request.path with the choice.remainder value.
# e.g. for this example, request.path will be "/get/1".
# Core will automatically replace that with "/get?id=1"
# before dispatching request to choice of upstream server.
choice.remainder += f'?id={result.groups()[0]}'.encode()
return choice