Alters and forwards incoming API requests
Project description
rest-api-proxy
Another DRF API proxy to redirect incoming requests to another API server, but with the option of altering the request and the response.
The original use case that motivated this implementation is to have a node responsible for the encryption/decryption of payloads, so that cryptographic keys are kept separated from the data.
TODO
- Add options to inject extra headers
- Add extra options to inject authentication data
- Add examples that alters requests
Usage
Setting the target server
The target server can be defined in settings.py by setting the HOST URL
entry in the REST_API_PROXY dictionary as follows:
# settings.py
REST_API_PROXY = {
'HOST': 'http://real-handler.com',
}
This can be set also directly to the instance via:
proxy = ProxyBase.as_view(proxy_settings={'HOST': 'http://real-handler.com'})
Request altering
Altering the request is achieved by extending the ProxyBase class.
class Proxy(ProxyBase):
def process_request(self, request):
# alter you request here
return request
def process_response(self, response):
# alter you response here
return response
Development
To install dependencies run:
uv sync --dev
Running tests
python runtests.py
License
rest-api-proxy is offered under the BSD-2-Clause license.
Credits
This work is inspired by django-api-proxy (Simplified BSD License).
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rest_api_proxy-0.1.1.tar.gz.
File metadata
- Download URL: rest_api_proxy-0.1.1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4ad43a548a8d07c930ccfcb74b752c4196425355fbf2cee5e88d9b3111ad3fda
|
|
| MD5 |
1039b158b9f5610f61fae5199fb4e355
|
|
| BLAKE2b-256 |
608bed51611abae10247c6d149ac196b6103c33c7fa2334ab426d123f4a44086
|
File details
Details for the file rest_api_proxy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: rest_api_proxy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35d39c9402dc744ee7ad9553271c86c1caa041fbaa3a05667bb37bfc63f3fb5b
|
|
| MD5 |
bddb6b282e715e2e4e5fd761acbf6a35
|
|
| BLAKE2b-256 |
18431fd21538ba4d1b8f2a7675e23467a4ae652f5372e08bb3e9213fbe9c54bb
|