nova icon indicating copy to clipboard operation
nova copied to clipboard

WIP: Fallback controller

Open burbas opened this issue 1 year ago • 0 comments

Phoenix have a very neat way of handling non-expected results of a controller via a fallback controller (https://hexdocs.pm/phoenix/Phoenix.Controller.html#action_fallback/1). This commit includes a similar way of handling this.

A fallback controller is defined by setting the attribute fallback_controller in a controller. If a non-expected result is returned from the controller then the fallback_controllers resolve/2 function is called with the arguments Req :: cowboy_req(), ControllerOutput :: any() where the ControllerOutput is result of executing the controller.

There's a few things to fix before we can merge this PR:

  • [x] Add documentation on how to use fallback controllers
  • [ ] Ensure that modules loads in releases (I had some problems with this so it might be a real issue)
  • [x] Write proper specs for the introduced functions

burbas avatar Oct 13 '22 16:10 burbas