Closed renchap closed 5 months ago
Did you consider overriding json_response_body
instead? You would need to serialize the hash to JSON yourself, but I think that would catch all scenarios.
@janko is correct, you want to use the json_response_body
configuration method to override the formatting of the response body.
I am using
return_json_response
to reformat Rodauth's responses so they match our general API patterns.Unfortunately, it seems that
_return_json_response
is used in some places when returning an error, for example when a JWT format is invalid (_return_json_response
is called directly), or whenrescue_jwt_payload
fromjwt_refresh.rb
is called (not sure whyreturn_json_response
is not called here?).I think it would make sense to either have all JSON responses go through the
return_json_response
method, or have areturn_json_error
you can customise.In our case, our JSON responses from the app are expected to have this format
I would like to remove the need for each app consuming the API to also handle the form used by Rodauth (
{ "error": "error_message" )
)