Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/karupanerura/router-simple.cr
simple path router inspired by Router::Simple.
https://github.com/karupanerura/router-simple.cr
Last synced: 2 months ago
JSON representation
simple path router inspired by Router::Simple.
- Host: GitHub
- URL: https://github.com/karupanerura/router-simple.cr
- Owner: karupanerura
- License: mit
- Created: 2015-07-26T17:28:18.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-23T10:46:05.000Z (over 8 years ago)
- Last Synced: 2024-04-13T08:10:05.898Z (3 months ago)
- Language: Crystal
- Homepage:
- Size: 141 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Lists
- awesome-crystal - router-simple.cr - Simple path router (HTTP)
README
# router-simple
simple path router inspired by [Router::Simple](https://metacpan.org/pod/Router::Simple).
## Installation
Add it to `Projectfile`
```crystal
deps do
github "karupanerura/router-simple.cr"
end
```## Usage
```crystal
require "router-simple"dispatcher = Router::Simple::Dispatcher(Hash(Symbol, String)).new()
dispatcher.add("/", {
:controller => "Root",
:action => "index",
})
dispatcher.add("/users/:user_id", {
:controller => "Users",
:action => "fetch_by_id",
})dispatcher.match("/") {|result|
p result.route.meta[:controller] # => "Root"
}dispatcher.match("/users/1") {|result|
p result.route.meta[:controller] # => "Users"
p result.match["user_id"] # => "1"
}
```## Development
TODO: Write instructions for development
## Contributing
1. Fork it ( https://github.com/karupanerura/router-simple.cr/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
- karupanerura(https://github.com/karupanerura) karupanerura - creator, maintainer