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

Usecase: redirect from before block #66

Open
vladfaust opened this issue Mar 1, 2019 · 1 comment
Open

Usecase: redirect from before block #66

vladfaust opened this issue Mar 1, 2019 · 1 comment
Labels

Comments

@vladfaust
Copy link
Member

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#halt method and @halted : Bool = false variable. Action#call checks if the @halted is false before 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.

@vladfaust vladfaust added the rfc label Mar 1, 2019
@vladfaust
Copy link
Member Author

See vladfaust/callbacks.cr#3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant