Commit Graph

126 Commits

Author SHA1 Message Date
Yang Bo
a77de09812 sort_by instead of sort
it is avoid sort errot within different and mixed keys.
used `sort_by` + `block` to list parameter by keys.
keep minimum changes
2015-04-08 22:18:56 +08:00
Aaron Patterson
12f2fc56aa Merge pull request #15806 from tgxworld/partition_routes_during_setup
Partition routes during setup.
2015-03-02 15:02:14 -08:00
Jeremy Kemper
a13e52b422 Revert "Merge pull request #18764 from tsun1215/master"
This reverts commit b6dd0c4ddebf5e7aab0a669915cb349ec65e5b88, reversing
changes made to de9a3748c436f849dd1877851115cd94663c2725.
2015-02-26 17:04:08 -07:00
Guo Xiang Tan
89edfbd3a4 Partition routes during setup.
Partitioning of all the routes is currently being done during the
first request. Since there is no need to clear the cache for
`partitioned_routes` when adding a new route. We can move the
partitioning of the routes during setup time.
2015-02-26 12:18:20 +08:00
Terence Sun
b9c63b0aae Explicitly ignored wildcard verbs from head_routes
In match_head_routes, deleted the routes in which request.request_method was empty (matches all HTTP verbs) when responding to a HEAD request. This prevents catch-all routes (such as Racks) from intercepting the HEAD request.

Fixes #18698
2015-02-08 12:03:56 -05:00
Rafael Mendonça França
21f02f3485 Remove some comments about Ruby 1.9 behaviors 2015-01-04 15:55:28 -03:00
Rafael Mendonça França
e4cfd353a4 Remove deprecated option use_route in controller tests 2015-01-04 11:58:41 -03:00
Sergey Alekseev
198b1dd201 remove unused #optional_parts
This method was copied from journey at 56fee39c39 (diff-2cfaf53c860732fea8689d6f2002594bR78).
`grep -nr 'optional_parts' .`
2014-12-05 16:21:17 +03:00
Sergey Alekseev
db00c5b7a4 remove unused #generalized_table
This method wass copied from journey at 56fee39c39 (diff-d89de8881fc4b9f10cb3e4fc7b2463f3R53). However it looks the method was unused in journey at those point as well.
2014-12-05 16:09:03 +03:00
Aaron Patterson
c9a5ed22d5 Merge pull request #17827 from rkh/rkh-fix-or-pattern
Fix OR in Journey patterns
2014-12-01 07:55:29 -08:00
Erik Michaels-Ober
d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
Konstantin Haase
0d690d75fb make OR in journey patterns compile to a valid regular expression 2014-11-29 01:26:10 +01:00
Bruno Sutic
3848bbe870
CSS fix for the router visualizer 2014-11-25 18:46:01 +01:00
Godfrey Chan
23b21f6182 Don't show the warning if we're already raising the error anyway
If the route set is empty, or if none of the routes matches with a score > 0,
there is no point showing the deprecation message because we are already be
raising the `ActionController::UrlGenerationError` mentioned in the warning.

In this case it is the expected behavior and the user wouldn't have to take any
actions.
2014-11-23 01:46:51 -08:00
Godfrey Chan
c23bb156fe Deprecate passing an invalid name to Formatter#generate
The internal tests that (incorrectly) relied on this were already fixed in
938d130. However, we cannot simply fix this bug because the guides prior to
b7b9e92 recommended a workaround that relies on this buggy behavior.

Reference #17453
2014-11-23 01:40:32 -08:00
Accessd
2224bf7992 fix url generation error message 2014-10-21 12:10:48 +04:00
Nicolas Cavigneaux
1c7dd65637 Use #tr instead of #gsub
`#tr` is more efficient than `#gsub` and can be used as a drop in
replacement in this context.
2014-10-14 22:32:23 +02:00
Nicolas Cavigneaux
3041bb2a94 Improve Journey compliance to RFC 3986
The scanner in Journey fails to recognize routes that use literals
from the sub-delims section of RFC 3986.

This commit enhance the compatibility of Journey with the RFC by
adding support of authorized delimiters to the scanner.

Fix #17212
2014-10-14 16:42:50 +02:00
Erik Michaels-Ober
2b6bacd192 Replace Array#shuffle.first with Array#sample 2014-10-13 11:54:04 +01:00
Guo Xiang Tan
d3eb92d95a Avoid duplicating routes for HEAD requests.
Follow up to rails#15321

Instead of duplicating the routes, we will first match the HEAD request to
HEAD routes. If no match is found, we will then map the HEAD request to
GET routes.
2014-08-21 16:35:39 +08:00
Jack Danger Canty
0b8f35dd9c Using no_result_var in Journey's parser generator
Previously the generated parser had an intermediate local variable
`result` that really useful if you're building up a stateful object but
Journey always discards the result argument to the reduce functions.

This produces a simpler parser for anybody who actually wants to read
the thing.

Sadly, there's no real performance speedup with this change.
2014-08-03 15:23:56 -07:00
Aaron Patterson
932386be8a recall should be path_parameters, also make it required
"recall" is a terrible name.  This variable contains the parameters that
we got from the path (e.g. for "/posts/1" it has :controller => "posts",
:id => "1").  Since it contains the parameters we got from the path,
"path_parameters" is a better name.  We always pass path_parameters to
`generate`, so lets make it required.
2014-07-17 11:26:59 -07:00
Karl Entwistle
8a29713134 Force encoding of US-ASCII to UTF-8 in unescape_uri.
Because URI paths may contain non US-ASCII characters we need to force
the encoding of any unescaped URIs to UTF-8 if they are US-ASCII.
This essentially replicates the functionality of the monkey patch to
URI.parser.unescape in active_support/core_ext/uri.rb.

Fixes #16104.
2014-07-10 10:02:11 +01:00
Viktar Basharymau
8ee785a17f Replace x.sort_by!.select! with x.select!.sort_by!
The latter has the same speed as the former in the worst case
and faster in general, because it is always better to sort less items.

Unfortunately, `routes.select!{...}.sort_by!{...}` is not possible here
because `select!` returns `nil`, so select! and sort! must be done
in two steps.
2014-06-20 17:16:11 +03:00
Larry Lv
4a9d4c85c3 Fix request's path_info when a rack app mounted at '/'.
Fixes issue #15511.
2014-06-14 04:57:33 +08:00
Aaron Patterson
da2cf937aa no more is_a checks on instantiation 2014-05-29 15:45:42 -07:00
Aaron Patterson
bb207ea7b6 Path::Pattern is instantiated internally, so make the contructor require a strexp object 2014-05-29 15:44:54 -07:00
Aaron Patterson
5682596db7 Strexp#names is only used in a test, so rm 2014-05-29 15:31:45 -07:00
Aaron Patterson
15ffbedf3b add an alternate constructor to Strexp that takes a string 2014-05-29 15:23:30 -07:00
Aaron Patterson
eabe504cdf ask the strexp for the ast 2014-05-29 15:16:40 -07:00
Aaron Patterson
3a102a58f4 use a parser to extract the group parts from the path 2014-05-29 14:57:48 -07:00
Aaron Patterson
cfdab77d1f Merge branch 'constraints'
* constraints:
  rm reset_parameters because we automatically do it from 9ca4839a
  move path_parameter encoding check to the request object
  dispatcher doesn't need `call` anymore
  call `serve` with the request on dispatchers
  constraints class does not need the request class anymore
  give all endpoints a superclass
  skip the build business if the stack is empty
  stop hardcoding path_parameters and get it from the request
  we do not need to cache rack_app
  a redirect is not a dispatcher by definition, so eliminate test
  push is_a check up to where the Constraints object is allocated
  pass the request object to the application
  pass a request to `matches?` so we can avoid creating excess requests
  nothing is passed to `rack_app` anymore, so rm the params
  one fewer is_a check
  Constraints#app should never return another Constraints object, so switch to if statement
  eliminate dispatcher is_a checks
  push is_a?(Dispatcher) check in to one place
  Always construct route objects with Constraint objects

Conflicts:
	actionpack/lib/action_controller/metal.rb
2014-05-27 14:40:55 -07:00
Santiago Pastorino
6f9aff75a5 Merge pull request #15321 from tgxworld/only_find_routes_as_heads_for_head_request
Call get_routes_as_head only on HEAD requests.
2014-05-27 14:46:49 -03:00
Aaron Patterson
b18f22d15c pass the request object to the application 2014-05-25 14:26:48 -07:00
Guo Xiang Tan
15df2a3c79 Call get_routes_as_head only on HEAD requests. 2014-05-25 13:51:53 -07:00
Guo Xiang Tan
586c346059 Remove unnecessary flatten! method call. 2014-05-25 00:17:23 -07:00
Aaron Patterson
633589c140 push is_a?(Dispatcher) check in to one place 2014-05-24 19:03:12 -07:00
Aaron Patterson
98c7fe8769 unwrap the constraints object on initialization, eliminate loops
Unwrap Constraints objects.  I don't actually think it's possible
to pass a Constraints object to this constructor, but there were
multiple places that kept testing children of this object.  I
*think* they were just being defensive, but I have no idea.
2014-05-24 17:52:22 -07:00
Franco Catena
aac85defa4 Fix router visualizer CSS and JS resources 2014-05-23 20:38:34 -03:00
Aaron Patterson
02f3081332 there is no formatter on the router object, so rm 2014-05-23 10:59:44 -07:00
Rafael Mendonça França
7d457e9c70 Merge pull request #15273 from DNNX/formatter-refactoring-4
Remove AD::Journey::Formatter#verify_required_parts!
2014-05-23 14:58:00 -03:00
Aaron Patterson
0f5e3a9f6b decouple the router object from the request class 2014-05-23 10:57:25 -07:00
Aaron Patterson
6fd8346400 pass the correct custom request to the recognize method 2014-05-23 10:57:25 -07:00
Aaron Patterson
6ed5b01f97 switch to the serve method so we can remove the request class (eventually) 2014-05-23 10:57:25 -07:00
Aaron Patterson
aaceca625d extract request allocation from the main app serving routine 2014-05-23 10:57:25 -07:00
Aaron Patterson
ca02296706 use the accessors on the request object rather than touching env 2014-05-23 10:17:57 -07:00
Aaron Patterson
559d89c5b3 find_routes only use the request, so stop passing env 2014-05-23 10:16:03 -07:00
Aaron Patterson
890e0a97fb remove NullRequest and just always pass a request class 2014-05-23 10:09:24 -07:00
Aaron Patterson
a6e94547e8 use the request object since we have it
stop hardcoding hash keys and use the accessors provided on the request
object.
2014-05-23 09:56:33 -07:00
Viktar Basharymau
fd03569210 Remove AD::Journey::Formatter#verify_required_parts!
Nobody uses this private method, maybe it is a leftover from some old
refactoring. Let's delete it.
2014-05-23 18:00:50 +03:00