Halt! docs misleading/incorrect
Opened this issue · 1 comments
For example, the docs show the controller:
class UserController < ApplicationController
def index
halt!(403, "Forbidden") if params[:user_id].nil?
render "index.slang"
end
end
and says
A status code of 403 was returned, and the content in render will not be delivered to the client.
which is not true. What really happens is that the client receives a response with the status of 403 but the content of the template. The core misunderstanding seems to be from a line further down that says
Unlike other frameworks Amber redirect_to stops the current execution of the request and performs the redirection at that given time...Since redirect_to uses the halt! method in the background.
I think there was a misunderstanding that calling halt!
does something to immediately return from whatever it's called in. Maybe it was envisioned to raise an exception? This was never the case, though. The only thing it does is set the content value on the context and the route
macro checks that value before running before_filters and the action https://github.com/amberframework/amber/blob/58eea3e147ba384fe4cb7c5f0a63da61b357e356/src/amber/dsl/router.cr#L14-L15
Would you like to open a PR to improve the docs? @matthewmcgarvey