An open API service indexing awesome lists of open source software.

https://github.com/dnlbauer/django-signposting

A Django middleware that adds FAIR signposting headers to HTTP responses, making your web application more FAIR.
https://github.com/dnlbauer/django-signposting

django fair fair-data links linkset rfc8288 signposting

Last synced: 11 months ago
JSON representation

A Django middleware that adds FAIR signposting headers to HTTP responses, making your web application more FAIR.

Awesome Lists containing this project

README

          

[![Python package](https://github.com/dnlbauer/django-signposting/actions/workflows/python-package.yml/badge.svg)](https://github.com/dnlbauer/django-signposting/actions/workflows/python-package.yml)

# FAIR signposting middleware for Django

`django_signposting` is a Django middleware library that facilitates the addition of
FAIR signposting headers to HTTP responses.
This middleware helps in making your data more FAIR (Findable, accessible, interoperable, reuseable) by
embedding signposting headers in responses, guiding clients to relevant resources linked to the response content.

Based on the [Signposting](https://github.com/stain/signposting) library.

## Features
- Automatically adds signposting headers to HTTP responses.
- Signposts can be added manually or automatically be parsed from JSON-LD/schema.org
- Supports multiple relation types with optional media type specification.
- Easily integrable with existing Django applications.

### Signposts are formatted and added as Link headers

```bash
curl -I http://localhost:8000
HTTP/2 200
...
link: ; rel="type" ,
; rel="author" ,
; rel="item" ; type="application/zip"
```

## Installation

```bash
pip install django-signposting
```

## Usage

### Automatic parsing of JSON-LD

The library can automatically add signposts to web pages that already make
metadata available via JSON-LD in HTML via `` tags, i.e.:

```HTML
<!DOCTYPE html>
<html>
<head>

<script type="application/ld+json">{"@context": "https://schema.org", "@type": ["WebSite", "Dataset"], "author": {"@type": "Person", "name": "Daniel Bauer", "url": "https://orcid.org/0000-0001-9447-460X"}, "description": "A dataset of things.", "hasPart": [{"@type": "ImageObject", "encodingFormat": "image/png", "url": "http://example.com/image.png"}, {"@type": "ImageObject", "encodingFormat": "image/png", "url": "http://example.com/image2.png"}], "license": {"@type": "CreativeWork", "name": "CC BY 4.0", "url": "https://creativecommons.org/licenses/by/4.0/"}, "name": "My Dataset", "sameAs": [{"@type": "MediaObject", "contentUrl": "https://example.com/download.zip", "encodingFormat": "application/zip"}, {"@type": "MediaObject", "contentUrl": "https://example.com/metadata.json"}], "url": "https://example.com"}

Hello, world!