Skip to content

How to implement endpoints for specific content-types #1584

Open
@eloo

Description

@eloo

Issue Description

How to implement endpoints for specific content-types

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Expected behaviour

I've have an PATCH endpoint which only accepts requests with content-type application/merge-patch+json

Actual behaviour

Not sure how to implement it

Details

I'm currently trying to create an endpoint which supports the https://tools.ietf.org/html/rfc7396 standard for patching resources.
But im struggling right now how to implement the specific content-type i want to accept.
So every request without the content-type to be set to application/merge-patch+json should be rejected with at 415.

My two ideas are the following:

  • In the handler function i just check the header manually and reject it with 415 if the content-type does not match
    or what i've found here so far
  • Create custom binder to bind the data which only accepts the specific content-type

I guess the second approach is the better but i'm not sure if there is maybe another solution or what should be prefered?

Thanks

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions