Metadata-Version: 2.4
Name: rest-api-proxy
Version: 0.0.1
Summary: Alters and forwards incoming API requests
Author-email: "Aeliton G. Silva" <aeliton@aeliton.com>
License-Expression: BSD-2-Clause
Project-URL: Homepage, https://github.com/aeliton/rest-api-proxy
Project-URL: Documentation, https://readthedocs.org
Project-URL: Repository, https://github.com/aeliton/rest-api-proxy.git
Project-URL: Issues, https://github.com/aeliton/rest-api-proxy/issues/
Project-URL: Changelog, https://github.com/me/spam/blob/master/CHANGELOG.md
Keywords: django,DRF,api-proxy,proxy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Libraries
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Framework :: Django :: 5.2
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS.md
Requires-Dist: djangorestframework>=3.16.1
Dynamic: license-file

# rest-api-proxy

Another [DRF](https://www.django-rest-framework.org/) 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:

```python
# settings.py
REST_API_PROXY = {
    'HOST': 'http://real-handler.com',
}
```

This can be set also directly to the instance via:

```python
proxy = ProxyBase.as_view(proxy_settings={'HOST': 'http://real-handler.com'})
```

## Request altering

Altering the request is achieved by extending the `ProxyBase` class.

```python
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

```bash
python runtests.py
```

# License

[rest-api-proxy](README.md) is offered under the BSD-2-Clause license.

# Credits

This work is inspired by
[django-api-proxy](https://github.com/aiselis/django-api-proxy/) (Simplified BSD
License).

