Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add standardization to HTTP response #18

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

zeeshanbhati
Copy link

  • Standardization of HTTP Response
    If this gets merged, the doc and frontend need to be updated

@lucifercr07
Copy link
Contributor

@zeeshanbhati please resolve the conflicts.
If we're going to standardise we shall try to find a way to differentiate between API request related errors and internal server errors and communicate them properly.
e.g. If a command is executed via API like GET k1 and k1 doesn't exists then it's an error from DB as nil which is valid and should be propogated as it is to client/UI.
If the API request is failed to parse or some panic occurs due to DB disconnect etc. we should wrap that error properly and convey differently so that UI can differentiate and give a generic response.

Please let me know your thoughts around this.

@zeeshanbhati
Copy link
Author

@lucifercr07 do we want to send the error as it is or do we need to add something or modify it that should be handled on the service layer, But that really does not change the format of the response added into this PR. unless you are getting gateway timed-out errors or your API is unreachable it should give a standard format response like

{
data: object or string,
error : Object or string,
hasData: boolean,
hasError: boolean,
}

An example could explain it better!

Please let me know what you think about this.

@zeeshanbhati zeeshanbhati force-pushed the refactor/response-standardiztion branch from 30fe4d1 to 9fe835a Compare October 9, 2024 20:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants