Page MenuHomeSoftware Heritage

api/async: add support for content negotiation
ClosedPublic

Authored by douardda on Jul 4 2019, 12:18 PM.

Details

Summary

For the content negotiation to work, we expect handler functions to
return straight data structures instead of Response objects so we can
handle the serialization in the "main" middleware (error_middleware,
which should probably be renamed).

It should still work with server handler implementations that do
produce Response object, but without the content negotitation feature
available then.

Related to T1871

Diff Detail

Repository
rDCORE Foundations and core functionalities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

This diff is a WIP since it uses the aiohttp_utils python package that has no debian package available for now.

douardda retitled this revision from api/async: add support for content negotiation to [WIP] api/async: add support for content negotiation.Jul 4 2019, 12:19 PM

add forgotten patch of requirements

douardda retitled this revision from [WIP] api/async: add support for content negotiation to api/async: add support for content negotiation.Jul 10 2019, 9:10 AM

I've published a new version of aiohttp_utils so this diff is no longer a wip

The debian package for aiohttp_utils is now available on debian.softwareheritage.org

This revision is now accepted and ready to land.Jul 11 2019, 3:42 PM

rework a bit the commit message

rework a bit the diff so that

it behaves more consistently wrt aiohttp: handlers are expected to
return Response objects, but when content negotiation is available (i.e.
when aiohttp_utils is present), handlers must return an aiohttp_utils.Response
object for the content negotiation to work properly.

Otherwise it should fall back to the former behavior (no content nego, always
render results as msgpack by default).

This revision was automatically updated to reflect the committed changes.