Skip to main content


Project description

1 Welcome to nlx_middleware’s documentation!








build-status Requirements status Coverage status

python-versions django-versions pypi-version

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:


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

Download files

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

Source Distribution

nlx-middleware-0.2.0.tar.gz (10.4 kB view hashes)

Uploaded source

Built Distribution

nlx_middleware-0.2.0-py2.py3-none-any.whl (11.2 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page