Change response message structure
See original GitHub issueI’m submitting a
- bug report.
- feature request.
Current Behaviour:
Right now hydrus returns a string as response message which contains the information related to object’s ID. If the client wants to access that, it has to use a regular expression to extract the ID from the message.
Expected Behaviour:
We can return a response in which object ID is separated from the verbal message, so a client can access it directly. Ex.
{
"message": "Object successfully created",
"object_id": "deede-w9d2wo-dkwd-fefrr3rt4"
}
@Guttz anything you want to add?
Steps to reproduce:
Do you want to work on this issue?
YES
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:8 (8 by maintainers)
Top Results From Across the Web
HTTP Messages - MDN Web Docs - Mozilla
HTTP requests, and responses, share similar structure and are ... HTTP/2 modify the HTTP message to divide them in frames (part of a....
Read more >Customize HTTP Responses | Documentation
ServiceStack provides multiple ways to customize your services HTTP response. Each option gives you complete control of the final HTTP Response that's ...
Read more >Change the message format to HTML, Rich Text Format, or ...
Change the format of a reply or a forwarded message You can change a plain text message to HTML. In the message, click...
Read more >HTTP/1.1: Response
The first line of a Response message is the Status-Line, consisting of the protocol version followed by a numeric status code and its...
Read more >Http Response- What is it? What is the structure of an HTTP ...
Every HTTP Response received as a result of an HTTP request sent by the client to the server has a status code. This...
Read more >Top Related Medium Post
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The spec mentions subclassing the Error and Status classes. It also allows us to add additional identifiers to the messages.
This means we can use the
@id
field in status and objects to provide URIs. In case of PUT/POST these can represent the URI for the instance. For DELETE, I don’t think we really need an ID in the response since the instance with that ID would have been deleted, just a 200 response would be enough.Does the spec say anything about the format of response messages? We should find that out.
Alternatively, we can return the modified object in case of PUT/POST. For DELETE the status code should be sufficient. The reason being that we would have a more standard response rather than ambiguous messages that we need to parse or custom objects where we define our own fields.
Also since all responses are HTTP responses, they have status codes by default. Unless there is an error we should use code 200 for responses. We already have appropriate status codes based on the error implemented in the exceptions.
EDIT: See #396