Releases: tbrand/router.cr
Releases · tbrand/router.cr
Crystal version 1.0
Formatted codes
v0.2.2 fmt
add leading / to Radix::Tree
Deprecate API (include a CRITICAL breaking change)
This release includes a CRITICAL breaking change, please read following to migrate from previous version.
- API to action by tbrand
What has been changed?
I decided to remove API (the alias of Proc) since I can implement router.cr by simpler way.
README.md has been updated for the new interface.
Following code shows how to migrate from previous version.
Previous version
class WebServer
include Router
@route_handler = RouteHandler.new
@index = API.new do |context, params|
context.response.print "Hello"
context
end
def initialize
draw(@route_handler) do
get "/", @index
end
end
def run
server = HTTP::Server.new(3000, @route_handler)
server.listen
end
end
Current version
class WebServer
include Router
def draw_routes
get "/" do |context, params|
context.response.print "Hello"
context
end
end
def initialize
draw_routes
end
def run
server = HTTP::Server.new(3000, route_handler)
server.listen
end
end
Deprecate profiler and renderer
Return 404 if route not found
This release includes following topics
- feat: return 404 if path not found #14 (Thanks @vladfaust)
route.cr to router.cr
Breaking change
Rename this repository from route.cr to router.cr. Please check README.md. 🚀
Speedup path lookup by avoiding object allocation
This release includes following features
- Use String.build to format_data in profile #10 (@veelenga) 🎉
- Speedup path lookup by avoiding object allocation #9 (@luislavena) 🎉
- Stop raising exception when the route not found #8
Merge context.request.query_params in to route.params
Updates
- Merge context.request.query_params in to route.params (@RomanHargrave)
- Extract path from resource string before searching routes (@RomanHargrave)
- Perf: Upcase http method during compile time (@splattael)
Thanks for the contributes:rocket:
Every PR or comments are welcome!
Add ProfileHandler
Now you can easily get a profile by accessing "/profile"
[ GET /one ] Access: 10 Total: 704.0µs Ave: 70.4µs
[ GET /two ] Access: 9 Total: 309.0µs Ave: 34.3µs
[ GET /three ] Access: 9 Total: 262.0µs Ave: 29.1µs
See sample to see how to use ProfileHandler.