Skip to content

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

@applejag

Description

@applejag

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreRoutine task, refactoring, or other changes not affecting end-users directly.prio/2Medium priority. "Good to have"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions