Skip to main content

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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

rest_api_proxy-0.0.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rest_api_proxy-0.0.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file rest_api_proxy-0.0.1.tar.gz.

File metadata

  • Download URL: rest_api_proxy-0.0.1.tar.gz
  • Upload date:
  • Size: 5.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.9.8

File hashes

Hashes for rest_api_proxy-0.0.1.tar.gz
Algorithm Hash digest
SHA256 7de222c0376e5ba237aee5a0121144ce3a5b95fda10d4ba914039f2065aa8f01
MD5 f44adb6477836d249a90ea4cb67bdd72
BLAKE2b-256 00d9fc6d68b42cce816e03053847b11035d2de132430858305c60e355b8329f8

See more details on using hashes here.

File details

Details for the file rest_api_proxy-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for rest_api_proxy-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5c9d9a95fe537a4f2043b69e9ef31b721439aab043c3f039f642bb0438c6366a
MD5 d20ef04334af4b48f1f7f9846c9c0b81
BLAKE2b-256 e560965a048b49fdb44673c072dc87e1db0ef37ffd3aa7d7e6e12ceb637ee7d0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page