[Enhancement]: Centralize response creation #160
Labels
awaiting-approval
Topic has not been approved or denied
enhancement
An update to an existing part of the codebase
Checked Existing
What enhancement would you like to see?
Create a helper function to centralize the creation of responses in some services. This is mainly aimed at NNAS but might be useful in other services as well.
The motivation behind this is the fact that our response creation is very clunky in a lot of places. Lots of repeated code, some areas missing things, lots of duplicate calls to set headers, etc.
I noticed this when looking at how #111 adds in a warning comment for the OAuth endpoint. This comment is supposed to warn users that sharing details could compromise their data like their device certificate (we know of at least 1 case of a user being tricked into giving up their device certificate this way, which was the motivation for the comment). I wanted to add this warning to other endpoints, since basically every NNAS endpoint needs it, and realized how much duplicate code that would be.
Any other details to share? (OPTIONAL)
I'm thinking maybe something like this?
This way we can easily just call the helper functions and have them set the headers and warning and all that
It should be noted that I'm unsure how exactly to handle situations where a NNAS error expects a format like:
Rather than:
It seems like sometimes the outer
<errors>
element is expected, and other times it is not. I could be mistaken about this though? @DaniElectra @shutterbug2000 @InternalLoss can we confirm if this is the case?The text was updated successfully, but these errors were encountered: