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

Fallback controller #192

Merged
merged 5 commits into from Oct 24, 2022
Merged

Fallback controller #192

merged 5 commits into from Oct 24, 2022

Conversation

burbas
Copy link
Contributor

@burbas burbas commented Oct 13, 2022

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:

  • 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)
  • Write proper specs for the introduced functions

@burbas burbas requested a review from Taure October 13, 2022 16:07
@burbas burbas changed the title WIP: Fallback controller Fallback controller Oct 16, 2022
@burbas burbas changed the title Fallback controller WIP: Fallback controller Oct 16, 2022
@burbas burbas changed the title WIP: Fallback controller Fallback controller Oct 21, 2022
@burbas
Copy link
Contributor Author

burbas commented Oct 21, 2022

@Taure Please review the latest changes and if everything looks alright we can merge it into master

@burbas burbas added enhancement New feature or request documentation Improvements or additions to documentation labels Oct 21, 2022
@Taure
Copy link
Collaborator

Taure commented Oct 21, 2022

Will test this branch and merge when tested.

@burbas burbas merged commit db18993 into master Oct 24, 2022
@burbas burbas deleted the fallback-contrller branch October 24, 2022 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants