Popularity
7.6
Stable
Activity
0.0
Stable
54
2
5
Programming language: Crystal
License: MIT License
Tags:
Framework Components
crouter alternatives and similar shards
Based on the "Framework Components" category.
Alternatively, view crouter alternatives based on common mentions on social networks and blogs.
-
shrine.cr
File Attachment toolkit for Crystal applications. Heavily inspired by Shrine for Ruby. -
Exception Page
An exceptional exception page for Crystal web libraries and frameworks -
praetorian
A minimalist Crystal authorization system inspired by https://github.com/varvet/pundit. -
motion.cr
Motion is a framework for building reactive, real-time frontend UI components in your Amber application using pure Crystal that are reusable, testable & encapsulated. -
kemal-auth-token
Kemal middleware to authentication via HTTP header token using JWT -
device_detector
Crystal shard for device detection by User-Agent string -
mochi
Mochi is a authentication shard inspired by devise. Mochi is designed for the Amber framework with support for both Granite & Jennifer ORM's. -
Athena Event Dispatcher
A Mediator and Observer pattern event library -
mime-types.cr
MIME Types for Crystal :: A port of the Ruby MIME::Types library -
request_id
Middleware for generates / pick up a unique request ID for Crystal servers. -
Athena Negotiation
Framework agnostic content negotiation library
Less time debugging, more time building
Scout APM allows you to find and fix performance issues with no hassle. Now with error monitoring and external services monitoring, Scout is a developer's best friend when it comes to application development.
Promo
scoutapm.com
Do you think we are missing an alternative of crouter or a related project?
README
crouter 
A standalone router for crystal
Features
- route params (also optional and nested optional)
- grouping under a prefix
- handle response with either block or seperate controller
- support for query params (also mixed with route params)
- most errors reveal themselves already at compile time
Benchmark results
Benchmarked with non-trivial route patterns. See [src/benchmark.cr](src/benchmark.cr). Due to performance optimizations compile-time increases with the amount of routes.
requests per second
without router (raw server throughput) 345.02k (± 3.91%) fastest
through router with 32 routes 248.48k (± 3.56%) 1.39× slower
through router with 64 routes 251.07k (± 3.57%) 1.37× slower
through router with 128 routes 126.84k (± 2.49%) 2.72× slower
through router with 256 routes 167.36k (± 3.69%) 2.06× slower
Installation
Add this to your application's shard.yml
:
dependencies:
crouter:
github: jreinert/crouter
Usage
require "crouter"
class MyController
private getter context, params
def initialize(@context, @params)
end
def my_action
# do something
context.response << "hi there"
end
end
class MyRouter < Crouter::Router
get "/" do
context.response << "hello world"
end
post "/path/with/:param" do
context.response << "you passed #{params["param"]}"
end
get "/path/with(/optional(/:parts))" do
context.repsonse << "you passed #{params["parts"]? || "nothing"}"
end
put "/handle/with/controller", "MyController#my_action"
group "/group" do
put "/routes", "MyGroupController#my_action"
group "/or/even/:nest" do
post "/them" do
context.response << "with params! #{params["nest"]}"
end
end
end
end
class MyRestAPI < Crouter::Router
group "/posts" do
get "/", "PostsController#index"
get "/:id", "PostsController#show"
get "/:id/edit", "PostsController#edit"
post "/", "PostsController#create"
put "/:id", "PostsController#update"
delete "/:id", "PostsController#delete"
end
end
puts "Listening on http://localhost:8989"
HTTP::Server.new(8989, [HTTP::LogHandler.new, MyRestAPI.new("/api"), MyRouter.new])
Contributing
- Fork it ( https://github.com/jreinert/crouter/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- jreinert Joakim Reinert - creator, maintainer