http
http copied to clipboard
Usecase: redirect from before block
struct MyAction
include Onyx::REST::Action
params do
query do
type redirect : Bool
end
end
before do
redirect("https://google.com") if params.query.redirect
end
end
Currently the callbacks.cr shard ignores the callbacks' return values.
Possible solutions:
Action#haltmethod and@halted : Bool = falsevariable.Action#callchecks if the@haltedisfalsebefore run
before do
halt(redirect("https://google.com")) if params.query.redirect
end
before do
puts "Will be put anyway"
end
But in this case further before callbacks are still run.
See https://github.com/vladfaust/callbacks.cr/issues/3.