TODO
Project description
1 Welcome to nlx_middleware’s documentation!
- Version:
0.1.0
- Source:
- Keywords:
<keywords>
- PythonVersion:
3.6
A Django middleware to integrate your service with NLx.
This middleware takes care of rewriting URLs in the linked-data responses if you’re operating in the NLx network. This makes it possible to use the NLx-outway URLs everywhere, while still saving/linking data against their canonical URLs.
2 Features
Rewriting of NLx outway URLs in the request body to canonical URLs
Rewriting of canonical URLs in the response body to NLx outway URLs
Rewrites URLs in GET query params
Leverages the OpenAPI schema to figure out what needs rewriting
2.1 TODO:
Set up registry of external services to rewrite as well
Support OAS 3.0 (via gemma-zds-client)
3 Installation
3.1 Requirements
Python 3.6 or above
setuptools 30.3.0 or above
Django 1.11 or above
django-rest-framework
the API schema must be available at {API_ROOT}/schema/openapi.yaml (currently Swagger 2.0 is supported)
gemma-zds-common (recommended)
3.2 Install
pip install nlx-middleware
4 Usage
Add the middleware to you MIDDLEWARE setting:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
...
'nlx_middleware.middleware.NLxInwayURLRewriteMiddleware',
]
We recommend to put it as close to the end as possible. Review the Django middleware documentation to see why the order matters.
Optionally, but recommended, add nlx_middleware to your INSTALLED_APPS. This makes models available where you can map external services to their canonical domains/addresses so that URLs not provided/served by your own project can also be rewritten.
If you don’t need this, then there’s (currently) no need to add it to your INSTALLED_APPS.
Next, ensure the following settings are defined:
NLX_SERVICE = os.getenv('NLX_SERVICE', 'zrc')
NLX_INWAY_ADDRESS = os.getenv('NLX_ADDRESS', 'localhost:8000')
NLX_ORGANIZATION = os.getenv('NLX_ORGANIZATION', 'vng-realisatie')
NLX_OUTWAY_ADDRESS = os.getenv('NLX_OUTWAY_ADDRESS', 'http://localhost:2018')
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
Hashes for nlx_middleware-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 471877a063877af822bf9553a79f3d66e9247f110e942c68157e1a568cb15e66 |
|
MD5 | d66dfabdc4559593dfe0d527484f099b |
|
BLAKE2b-256 | 89f30e6db0c4ca5e89f9f03f18449b40f3fa2f04bb71f52fff7d7b8dcbda7498 |