Replies: 1 comment
-
Hi @dkbarn! One way could be simply adding all handlers, and checking See, for instance, this type of check in our Quickstart docs (performed in middleware): if req.method in ('POST', 'PUT'):
if 'application/json' not in req.content_type:
raise falcon.HTTPUnsupportedMediaType(
title='This API only supports requests encoded as JSON.',
href='http://docs.examples.com/api/json') Furthermore, maybe it's not a big deal to have all media handlers registered for the whole app? If the above doesn't fit your bill, we could file a new enhancement proposal issue. |
Beta Was this translation helpful? Give feedback.
-
What is the correct way to support a specific Content-Type for only a subset of resources?
Example: I have a falcon App with multiple resources/endpoints, some are GET only and return health check statuses, etc. Some of the endpoints allow GraphQL queries via POST. For these resources, I want to register a custom media handler for the "application/graphql" content type.
It seems that media handlers are assigned to the RequestOptions of the application as a whole. But it doesn't make sense for all of my endpoints to receive GraphQL queries. What is the recommended way of handling this scenario?
Beta Was this translation helpful? Give feedback.
All reactions