Search code examples
resthanami

How to set 404 error response format to JSON in Hanami


I'm writing REST API for application with Hanami ruby web framework, and I'm wondering how to set error format to JSON. For example,when 404 error occurred it should return response with body {'message': 'Method not found'}, and Content-Type: 'application/json'


Solution

  • You need to set format to json.

    format: :json
    

    See Mime Types Documentation