Feature #27117

Work Package #45088: Improved REST support

Bind routes to HTTP request methods

Added by Fernando Arconada about 4 years ago. Updated about 2 years ago.

Status:Resolved Start date:2011-05-29
Priority:Should have Due date:2013-04-13
Assigned To:Bastian Waidelich % Done:

100%

Category:MVC - Routing
Target version:TYPO3 Flow Base Distribution - 2.0
PHP Version: Complexity:
Has patch:No

Description

Routes need an option to be limited to certain HTTP methods:

Limit one route to a HTTP method as in Symfony
-
name: 'empresa actions'
uriPattern: 'empresa/{@action}(/{empresa})'
defaults:
'@package': Sifpe
'@controller': Empresa
'@action': list
'@format': json
requirements:
_method: POST|PUT

as in symfony2
http://symfony.com/doc/current/book/routing.html


Related issues

related to TYPO3.Flow - Feature #27116: Routing: Declared variables only available in POST but no... Closed 2011-05-29
related to TYPO3.Flow - Feature #28136: HTTP Semantics for Transactions and more New 2011-07-12
related to TYPO3.Flow - Feature #37604: Make Flow RestController useless by improving MVC stack Resolved 2012-05-30

Associated revisions

Revision 0b629987
Added by Bastian Waidelich about 2 years ago

[FEATURE] Bind routes to HTTP request methods

This change allows routes to be limited to certain request methods.
This is especially useful for REST services where you often need the
same URI to invoke different actions depending on the HTTP method.

Usage::

-
uriPattern: 'foo/bar'
defaults:
'@package': 'Some.Package'
'@controller': 'Standard'
'@action': 'first'
httpMethods: ['GET']
-
uriPattern: 'foo/bar'
defaults:
'@package': 'Some.Package'
'@controller': 'Standard'
'@action': 'second'
httpMethods: ['POST', 'PUT']

Change-Id: I1d53d20ac4675bc0cc4e58a33c08a656383f1a9f
Resolves: #27117
Releases: master, 2.0

Revision 07ab7988
Added by Bastian Waidelich about 2 years ago

[FEATURE] Bind routes to HTTP request methods

This change allows routes to be limited to certain request methods.
This is especially useful for REST services where you often need the
same URI to invoke different actions depending on the HTTP method.

Usage::

-
uriPattern: 'foo/bar'
defaults:
'@package': 'Some.Package'
'@controller': 'Standard'
'@action': 'first'
httpMethods: ['GET']
-
uriPattern: 'foo/bar'
defaults:
'@package': 'Some.Package'
'@controller': 'Standard'
'@action': 'second'
httpMethods: ['POST', 'PUT']

Change-Id: I1d53d20ac4675bc0cc4e58a33c08a656383f1a9f
Resolves: #27117
Releases: master, 2.0

Revision d62a2285
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix configuration schema for Routes

This adjusts the Routes.schema.yaml to the "httpMethods"
setting introduced with #27117

Change-Id: I2531096162ed16060c2efd6f8a5328233855f884
Related: #27117
Releases: master, 2.1, 2.0

Revision 3b8223c2
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix configuration schema for Routes

This adjusts the Routes.schema.yaml to the "httpMethods"
setting introduced with #27117

Change-Id: I2531096162ed16060c2efd6f8a5328233855f884
Related: #27117
Releases: master, 2.1, 2.0

Revision f69ebd44
Added by Bastian Waidelich over 1 year ago

[BUGFIX] Fix configuration schema for Routes

This adjusts the Routes.schema.yaml to the "httpMethods"
setting introduced with #27117

Change-Id: I2531096162ed16060c2efd6f8a5328233855f884
Related: #27117
Releases: master, 2.1, 2.0

History

#1 Updated by Bastian Waidelich about 4 years ago

  • Category set to MVC - Routing
  • Status changed from New to Accepted
  • Assigned To set to Bastian Waidelich

#2 Updated by Bastian Waidelich about 3 years ago

  • Target version set to 2.0 beta 1
  • Has patch set to No

Sorry for the delay on this one, but this needs to be done right from the beginning (for instance those constraints need to provide some kind of cache identitifier so that we can re-enable the caching aspect for the routing).

This feature will come and it will probably be extensible for other constraints (for example domains). Hopefully in 1.2!

#3 Updated by Bastian Waidelich over 2 years ago

  • Subject changed from Routing: restrict available HTTP methods and use them in routing signature to Global Route Constraints

#4 Updated by Karsten Dambekalns over 2 years ago

  • Target version changed from 2.0 beta 1 to 2.1

#5 Updated by Bastian Waidelich over 2 years ago

  • Parent task set to #45088

#6 Updated by Aske Ertmann over 2 years ago

  • Parent task deleted (#45088)

#7 Updated by Aske Ertmann over 2 years ago

  • Parent task set to #45088

#8 Updated by Bastian Waidelich over 2 years ago

  • Due date set to 2013-04-06

#9 Updated by Bastian Waidelich over 2 years ago

  • Due date changed from 2013-04-06 to 2013-04-13

#10 Updated by Gerrit Code Review over 2 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19742

#11 Updated by Bastian Waidelich over 2 years ago

I created a (really simple) package that demonstrates this feature: https://github.com/bwaidelich/Wwwision.RouteConstraintTest

#12 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19742

#13 Updated by Bastian Waidelich over 2 years ago

  • Subject changed from Global Route Constraints to Bind routes to HTTP request method
  • Target version changed from 2.1 to 2.0

Ok, that took some doing..
After experimenting with "Global Route Constraints" for a long time I think my approach (https://review.typo3.org/#/c/19742/) was too complex and it still has some caching issues.
I still think that this feature would be very neat (e.g. for versioning APIs on the basis of the Accept header). But I figured that the very feature of limiting routes to certain request methods should be a "core feature" – also for performance reasons.

The good news:
With a little bit of luck this will make it into 2.0.

The syntax will (probably) be:

 1-
 2  uriPattern: 'foo/bar'
 3  defaults:
 4    '@package':    'Some.Package'
 5    '@controller': 'Standard'
 6    '@action':     'first'
 7  acceptedHttpMethods: ['GET']
 8
 9-
10  uriPattern: 'foo/bar'
11  defaults:
12    '@package':    'Some.Package'
13    '@controller': 'Standard'
14    '@action':     'second'
15  acceptedHttpMethods: ['POST', 'PUT']

changeset follows

#14 Updated by Bastian Waidelich over 2 years ago

  • Subject changed from Bind routes to HTTP request method to Bind routes to HTTP request methods

#15 Updated by Gerrit Code Review over 2 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#16 Updated by Gerrit Code Review over 2 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#17 Updated by Gerrit Code Review over 2 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#18 Updated by Bastian Waidelich over 2 years ago

  • % Done changed from 0 to 90

(only needs to be merged)

#19 Updated by Gerrit Code Review over 2 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#20 Updated by Gerrit Code Review over 2 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#21 Updated by Gerrit Code Review over 2 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#22 Updated by Gerrit Code Review about 2 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#23 Updated by Gerrit Code Review about 2 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#24 Updated by Gerrit Code Review about 2 years ago

Patch set 1 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/21241

#25 Updated by Gerrit Code Review about 2 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#26 Updated by Gerrit Code Review about 2 years ago

Patch set 2 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/21241

#27 Updated by Gerrit Code Review about 2 years ago

Patch set 3 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/21241

#28 Updated by Gerrit Code Review about 2 years ago

Patch set 4 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/21241

#29 Updated by Gerrit Code Review about 2 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#30 Updated by Gerrit Code Review about 2 years ago

Patch set 11 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#31 Updated by Gerrit Code Review about 2 years ago

Patch set 5 for branch 2.0 has been pushed to the review server.
It is available at https://review.typo3.org/21241

#32 Updated by Gerrit Code Review about 2 years ago

Patch set 12 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/19801

#33 Updated by Bastian Waidelich about 2 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 90 to 100

Also available in: Atom PDF