borisbu / OctoRelay

OctoPrint / Octopi plugin to control relays
GNU Affero General Public License v3.0
43 stars 25 forks source link

Ref: API: Moving response shaping out of handlers #240

Closed RobinTail closed 11 months ago

RobinTail commented 11 months ago

Contributes to #164

No breaking changes to the API yet, but preparing for introducing its new version by extracting the response shaping outta handlers. So the on_api_command method will be the only one who operates flask.

Handlers, on the other hand, are either return data OR raise exceptions.

For that, introducing also HandlingException class, accepting the HTTP status code that is supposed to be used for managing the response in case of an error raised during handling the request.

Preserving (for now) the original behaviour of update command, which in case of disabled relay responds with status: error instead of aborting.

coveralls commented 11 months ago

Coverage Status

coverage: 100.0%. remained the same when pulling ee6ebd06358932d093b53b8880d193e5616c49a5 on issue-164-api-inconsistency into 253707749ab1fef1249acd70275aac4c27248a61 on develop.