Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 Hanami ruby Web 框架为应用程序编写 REST API,我想知道如何将错误格式设置为 JSON。例如,当发生 404 错误时,它应该返回带有正文的响应{'message': 'Method not found'}, and Content-Type: 'application/json'
{'message': 'Method not found'}, and Content-Type: 'application/json'
您需要将格式设置为 json。
format: :json
请参阅 Mime 类型文档