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

Refactor: return problem.Response as error instead of -WritesProblem() #29

Open
applejag opened this issue Aug 31, 2021 · 0 comments
Open
Labels
chore Routine task, refactoring, or other changes not affecting end-users directly. prio/2 Medium priority. "Good to have"

Comments

@applejag
Copy link
Contributor

Currently to have fine-grained problem responses we have a lot of functions/methods with the suffix "-WritesProblem" and then returns true if they succeeded or false if they failed and wrote a problem to the gin context.

This would need us to add "NewProblem..." functions to the wharf-core/pkg/ginutil package, and a utility function that wrotes a returned problem response to the HTTP response, or converts a non-problem response to a problem response and then writes that instead to the HTTP response.

This way we could offload a lot of work from the endpoint methods by only using return values. Maybe we could wrap the functions as well so instead of being func(*gin.Context) to be func(*gin.Context) error where it uses that error->problem.Response that I mentioned in the above paragraph.

Just a thought. Could need an RFC to show both the wharf-core changes as well as the changes to the API repos as this would involve a lot of work and the specific implementation needs a good overview.

@applejag applejag added the enhancement New feature or request label Aug 31, 2021
@applejag applejag added chore Routine task, refactoring, or other changes not affecting end-users directly. prio/2 Medium priority. "Good to have" and removed enhancement New feature or request labels Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Routine task, refactoring, or other changes not affecting end-users directly. prio/2 Medium priority. "Good to have"
Projects
None yet
Development

No branches or pull requests

1 participant