tbrand / router.cr Goto Github PK
View Code? Open in Web Editor NEWMinimum High Performance Middleware for Crystal Web Server.
License: MIT License
Minimum High Performance Middleware for Crystal Web Server.
License: MIT License
I don't want to step on your toes here but how about writing some more descriptive commit messages in the future? :) "Fix" doesn't tell me much. :P
The Crystal community has somewhat decided to use crystal
as the language's topic.
To avoid fragmentation in the community, please drop crystallang
and crystal-language
topics, that only have ~12 or ~28 repositories at the moment. We're sticking to crystal
, instead.
Any contributor can change it from the repo's homepage.
See crystal-lang/crystal#4241 for more context.
Thank you very much :)
You should be able to combine multiple handlers that can handle different routes (e.g. a handler for /favicon.ico or a monitoring API, etc...)
Route::RouteHandler#call(context)
raises an exception when it can't route rather than "passing the torch" to the next handler. This makes combining routers impossible.
Given the route specification /:id
I should be able to request /12345?param=value
and have
the router break down the params as {"id": "12345", "param": "value"}
, instead the parameters are given as {"id": "12345?param=value"}
.
Hi @tbrand,
I can see on README
that version is pin to 0.2.2
However, the last version is 0.2.4
Regards,
I think nobody use this...
Hello, @tbrand !
Error occuried when i'am trying shards install
shard.yml
name: test
version: 0.1.0
authors:
- test <[email protected]>
targets:
test:
db: src/test-db.cr
api: src/test-api.cr
dependencies:
router:
github: tbrand/router.cr
license: MIT
Hello,
I've checked your project and it either:
Your project is in Awesome Crystal list, so I'd like to ask if the project maintained?
I'll initiate a PR to remove your project from the list if you don't respond positively within 7 days.
I'm sorry if I'm wrong, because I've been checking many shards with automated script.
Thanks,
Vlad.
Hi @tbrand, I like router.cr as middleware.
Would be possible to add router.cr to https://github.com/TechEmpower/FrameworkBenchmarks ?
TFB have three categories:
I think router.cr can compete in the first category, What do you think?
Tests for crystal-raw: https://github.com/TechEmpower/FrameworkBenchmarks/tree/master/frameworks/Crystal/crystal
Currently if the route not found it doesn't touch the default response and returns 200 status code.
Is there an example for how to retrieve POST params from an HTML form? router.cr seems to ignore GET and POST params, only providing the params available in the URL (e.g., '/posts/:post_id').
Am I missing something? Or is that a limitation of this router framework?
This makes shards think it has to fetch the repo on every build. To fix this the git tag should match the version in shards.yml
As addition to use block handler, it would be nice to add method handler or class handler to make the router code cleaner and follow separation of concern.
# block handler
get "/" do |context, params|
context.response.print "Hello router.cr!"
context
end
# method handler
get "/" home
post "/user" add_user
def home(context, params) : HTTP::Server::Context
context.response.print "Hello router.cr!"
context
end
# class handler
article = Article.new
get "/article/:id" article.get
put "/article/:id" article.update
class Article
def get(context, params)
context.response.print "Hello router.cr!"
context
end
end
Is it possible to improve performance if the router could convert string to bytes using to_slice?
From the benchmark, to_slice would cost <4 nanoseconds and efficient to compare using ==
Range 17.51M ( 57.11ns) (±10.77%) 32 B/op 14.44× slower
Slice 252.8M ( 3.96ns) (± 5.81%) 0 B/op fastest
Range:
key[0..-2]
Slice:
(key.to_slice)[0,key.size-2]
What is best way to separate route in different class. I'm thinking to create modular app and each has its own route declaration.
When a server is accessed with a path, it idiomatically triggers something a.k.a. an action happens. My proposal is to replace API (alias API = Proc(HTTP::Server::Context, Hash(String, String)
) with Action.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.