Skip to content

Add support for dynamic reverse proxy routing #1180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Jun 11, 2022

Conversation

abhinavsingh
Copy link
Owner

@abhinavsingh abhinavsingh commented Jun 5, 2022

Plugins must implement the def handle_route(self, request: HttpParser, pattern: re.Pattern[Any]) -> 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.

Fixes #1132

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.
@abhinavsingh abhinavsingh added the bot:chronographer:skip PR using this label is exempted from CHANGELOG management label Jun 5, 2022
@abhinavsingh
Copy link
Owner Author

@piraz @rpgmaster280 Please take a look at this PR. I have updated the example plugin with a dynamic route implementation. You'll need to write a plugin to handle your own custom dynamic routes. Best

@codecov
Copy link

codecov bot commented Jun 5, 2022

Codecov Report

Merging #1180 (d90c58a) into develop (c3b966e) will decrease coverage by 0.09%.
The diff coverage is 68.25%.

❗ Current head d90c58a differs from pull request most recent head 7d68902. Consider uploading reports for the commit 7d68902 to get more accurate results

@@             Coverage Diff             @@
##           develop    #1180      +/-   ##
===========================================
- Coverage    87.24%   87.15%   -0.10%     
===========================================
  Files          166      166              
  Lines         6971     7012      +41     
  Branches       708      719      +11     
===========================================
+ Hits          6082     6111      +29     
- Misses         766      779      +13     
+ Partials       123      122       -1     
Flag Coverage Δ
pytest 86.95% <65.07%> (-0.13%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
proxy/plugin/reverse_proxy.py 60.00% <55.55%> (-40.00%) ⬇️
proxy/http/server/reverse.py 83.07% <60.86%> (-9.79%) ⬇️
proxy/http/server/plugin.py 91.37% <80.00%> (-4.18%) ⬇️
proxy/common/types.py 100.00% <100.00%> (ø)
proxy/http/handler.py 76.10% <0.00%> (+0.88%) ⬆️
proxy/core/work/threadless.py 83.25% <0.00%> (+1.97%) ⬆️

📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more

@abhinavsingh abhinavsingh merged commit 7195b07 into develop Jun 11, 2022
@abhinavsingh abhinavsingh deleted the dynamic-reverse-proxy branch June 11, 2022 17:14
abhinavsingh added a commit that referenced this pull request Jun 11, 2022
* 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](Neoteroi/BlackSheep@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] <[email protected]>

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](fregante/setup-git-user@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] <[email protected]>

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](TypeStrong/ts-node@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] <[email protected]>

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](websockets/ws@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] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Abhinav Singh <[email protected]>

* 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](pytest-dev/pytest@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] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Abhinav Singh <[email protected]>

* 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](python-rope/rope@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] <[email protected]>

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](encode/starlette@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] <[email protected]>

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](python/mypy@v0.940...v0.960)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

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](actions/cache@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] <[email protected]>

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](actions/setup-python@v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

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](benfred/py-spy@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] <[email protected]>

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](python/mypy@v0.960...v0.961)

---
updated-dependencies:
- dependency-name: mypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot:chronographer:skip PR using this label is exempted from CHANGELOG management
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make it possible to have a dynamic reverse proxy
1 participant