Skip to content

Instantly share code, notes, and snippets.

@qszhu
Created May 24, 2019 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qszhu/b31fa84f47a4c17581ff1dc21daa7049 to your computer and use it in GitHub Desktop.
Save qszhu/b31fa84f47a4c17581ff1dc21daa7049 to your computer and use it in GitHub Desktop.
```crystal
require "onyx/http"
Onyx::HTTP.get "/" do |env|
env.response << "Hello, Onyx!"
end
Onyx::HTTP.post "/foo" do |env|
env.response << "bar"
end
Onyx::HTTP.listen do |handlers|
router_middleware = handlers[-2].as(Onyx::HTTP::Middleware::Router)
pp router_middleware.@hash.keys # ["/get", "/post/foo"]
end
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment