HomeSoftware Heritage

Add support for content negotiation in swh's API

Description

Add support for content negotiation in swh's API

Using these 2 negotiate formatters, it is possible to write Flask endpoints
as:

from flask import Flask
from negotiate.flask import negotiate
from swh.core.api import JSONFormatter, MshpackFormatter

app = Flask()

@app.route('/somewhere')
@negotiate(MsgpackFormatter)
@negotiate(JSONFormatter)
def somewhere():
    return {'some': 'content'}

See https://github.com/nickstenning/negotiate

Details

Provenance
douarddaAuthored on Jan 23 2019, 4:43 PM
douarddaPushed on Jan 24 2019, 3:48 PM
Differential Revision
D992: Add support for content negotiation in swh's API
Parents
rDCORE24f9d5ee2b73: Log used config files.
Branches
Unknown
Tags
Unknown
Build Status
Buildable 3688
Build 4811: test-and-build