Skip to content

views: fix calls to make_response (API for REST views) #44

Description

@lnielsen

Problem:

When you define a view method in a subclass of ContentNegotiatedMethodView you can currently return (retval):

  • a response (no call to make_response())
  • a list/tuple which will call make_response(*retval)
  • anything else which will call make_response(retval)

See here

This causes confusion with Flask's make_response which behaves differently, and it also makes it hard to 1) get a consistent API for serialisers over many modules 2) change simple things like e.g. response code while keeping the serialiser the same.

Example:
GET/POST serialisation of an object is likely the same, but often response code will be 200 vs 201/202.

Proposals

  • A) Always just call make_response() explicitly from views
  • B) Align with Flask's make_response() and allow either 1) a response (already possible today) or 2) a 2/3-tuple of (response, status, headers) or (response, headers)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions