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

with self yield in router #25

Open
watzon opened this issue Sep 19, 2019 · 1 comment
Open

with self yield in router #25

watzon opened this issue Sep 19, 2019 · 1 comment

Comments

@watzon
Copy link

watzon commented Sep 19, 2019

If the #on method were to yield as with self yield self rather than simply yield self it would switch the entire context to self rather than just yielding self to the block. This would allow for slightly more idomatic routing as you could then do

Onyx::HTTP.on "/api" do
  get "/ping", Endpoints::API::Ping
end

Instead of

Onyx::HTTP.on "/api" do |router|
  router.get "/ping", Endpoints::API::Ping
end
@vladfaust vladfaust transferred this issue from onyxframework/http Sep 20, 2019
@vladfaust
Copy link
Member

May be. Try to play with

Onyx::HTTP::Singleton.instance.router.on(*args, **nargs, &block)

To see how it would work.

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

No branches or pull requests

2 participants