Home > Software engineering >  Can I include extra information with a head :forbidden response?
Can I include extra information with a head :forbidden response?

Time:08-07

Can't seem to find any resources on this. We have multiple "Permission" based errors that should be handled differently by the client, but they all definitely fall under the umbrella of needing additional permissions, semantically should be a 403.

With rails, can I include extra info that can be interpreted by the client? i.e.

head :forbidden, message: 'RequiresLevel2'

so the client could then handle the 'RequiresLevel2' properly.

Using Rails/React, so I don't need help with the erb side of things.

CodePudding user response:

According to Mozilla, the head http response should not include a body (https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/HEAD).

Why not just respond with status: :forbidden and include the body you want to send?

  • Related