sematic
sematic copied to clipboard
Refactor and centralize Flask response handling
Refactoring ideas:
-
JSON conversion (including calling
to_json_encodeable()
andflask.jsonify()
) can be done in a after_request hook. This way we have a dedicated place to convert JSONEncodableMixin universally. Also in the future, we can add logic in reacting to different requested "content-type" (eg. xml) in a centralized way. This API endpoint function only needs to focus on business logic. -
Together with the above, we should consider adopting Blueprint to divide business domains and scope hooks usage.