gallery.accords-library.com/szurubooru/middleware/require_json.py

13 lines
394 B
Python
Raw Normal View History

''' Exports RequireJson. '''
import falcon
class RequireJson(object):
''' Sanitizes requests so that only JSON is accepted. '''
def process_request(self, req, resp):
''' Executed before passing the request to the API. '''
if not req.client_accepts_json:
raise falcon.HTTPNotAcceptable(
'This API only supports responses encoded as JSON.')