Right now every `match?` performed against the routes defined result
in a new Regex compiled for the exact same `@path`.
Since `@path` of the Route does not change on every request, we
pre-build it to avoid repeated allocations.
When testing this in release mode (against 0.10.2 [d1e3f0b]):
Before: 32408.48 req/s
After: 34862.07 req/s
Following are the changes made in this commit:
- Added support for magic param `_method` just like Rails, Sinatra
etc.. Browsers which don't support `PUT`, `PATCH` and `DELETE` methods
can simulate them by sending `method` param in request body.
- The default Content-Type to parse request body submitted via forms
etc. is `application/x-www-form-urlencoded`. But if we send Ajax
request in Chrome ($.post) then by-default Content-Type is set to
`application/x-www-form-urlencoded; charset utf-8` which was not
getting matched. I changed the code from `==` to match against a
regular expression using `=~`.
- Print name and color of overridden HTTP method via Logger instead of
printing name and color or request's incoming HTTP method.
Making necessary changes as pointed by @sdogruyol
- Changed method name from`is_override_method_valid?` to
`override_method_valid?`.
- Refactored `if` condition in `override_method_valid?`.