RedHatInsights / insights-api-common-rails

Header, Encryption, RBAC, Serialization, Pagination and other common behavior for Insights microservices built with Rails
Apache License 2.0
3 stars 25 forks source link

Use rack to get proper status code #179

Closed mkanoor closed 4 years ago

mkanoor commented 4 years ago

Fixes #178 Uses Rack::Utils.status_code to convert the Rails HTTP error symbols to numeric values. The status_code can handle integers/strings/symbols and returns the appropriate numeric value e.g.

Rack::Utils.status_code(400) => 400 Rack::Utils.status_code("400") => 400 Rack::Utils.status_code(:forbidden) => 403

The JSON API Error Object Sample https://jsonapi.org/examples/#error-objects-basics

The status value should be https://jsonapi.org/format/#errors status: the HTTP status code applicable to this problem, expressed as a string value.