routing
Version, currently master branch1 version
- master branchlatestJan 17, 2020
github.com/bcardiff/crystal-routing
Extensible library to deal with http request and string based routing in Crystal
31 stars
0 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
routing:
github: bcardiff/crystal-routing
branch: mastermaster is a branch, not a release, so this tracks it rather than pinning a version.
Then run:
shards installshard.yml
- Crystal
0.32.1- License
- MIT
- Author
- Brian J. Cardiff <bcardiff@gmail.com>
Dependencies
This version declares no dependencies.
Documentation
Generated from the source of the current release. The first visit to a release that has never been documented starts its build.
README
# crystal-routing
[](https://travis-ci.org/bcardiff/crystal-routing)
Extensible library to deal with http request and string based routing in Crystal.
Features:
* Building blocks to define others routing/delegation mechanisms
* Compiled time check method invocation
## Installation
Add this to your application's `shard.yml`:
```crystal
dependencies:
routing:
github: bcardiff/crystal-routing
```
## Usage
```crystal
# file: app.cr
require "http/server"
require "routing"
class FooController
include Routing::Routable
def method1
HTTP::Response.ok "text/plain", "method1"
end
def method2
HTTP::Response.ok "text/plain", routing_context.params["id"]
end
end
module App
class Routes
include Routing::HttpRequestRouter
get "m1", "foo#method1"
get "foo/:id", "foo#method2"
root "foo#method1"
end
end
routes = App::Routes.new
server = HTTP::Server.new(8080) do |request|
routes.route(request)
end
puts "Listening on http://0.0.0.0:8080"
server.listen
```
Run the server
```
$ crystal app.cr
```
Use the server
```
$ curl http://localhost:8080
method1
$ curl http://localhost:8080/m1
method1
$ curl http://localhost:8080/foo/42
42
```
More in samples and specs
## Development
TODO: Write instructions for development
## Contributing
1. Fork it ( https://github.com/bcardiff/crystal-routing/fork )
2. Create your feature branch (git checkout -b my-new-feature)
3. Commit your changes (git commit -am 'Add some feature')
4. Push to the branch (git push origin my-new-feature)
5. Create a new Pull Request
## Contributors
- [bcardiff](https://github.com/bcardiff) Brian J. Cardiff - creator, maintainer
Links
This branch
- Branch
master- Seen
- Jan 17, 2020
- Crystal
0.32.1- Indexed
- yes
Dependents
No indexed shard depends on this one yet.
Repository
github.com/bcardiff/crystal-routing
Metadata
- Created
- Aug 12, 2026
- Updated
- Aug 12, 2026
- Synced
- Aug 12, 2026
- Versions
- 1