[Flow] Routes and optional arguments/parameters

Søren Malling soren.malling at gmail.com
Mon Oct 14 15:50:45 CEST 2013


Hi Bastian,

Thanks for the hint.

My configuration, mathcing my needs ended up like this

-
  name : 'API, Single'
  uriPattern: 'api/{@action}/{object}'
  httpMethods: ['POST', 'GET', 'PUT', 'DELETE']
  defaults:
    '@package': 'Vendor.Package'
    '@controller': 'Rest'
    '@format': 'json'

-
  name : 'API, General'
  uriPattern: 'api(/{@action})'
  httpMethods: ['POST', 'GET', 'PUT', 'DELETE']
  defaults:
    '@package': 'Vendor.Package'
    '@controller': 'Rest'
    '@format': 'json'
    '@action': 'help'


Can you tell about the current status of the built in Rest support you have
been working on? Should I go different direction, than trying to create my
own Rest API ?

Cheers

Søren


On Mon, Oct 14, 2013 at 3:08 PM, Bastian Waidelich <bastian at typo3.org>wrote:

> Søren Malling wrote:
>
> Hi Søren,
>
>  I'm writing my own API at the moment for a project and I'm in the part of
>> configuring my routes [...]
>>
>
>  -
>>    name : 'API'
>>    uriPattern: 'api/{@action}(/{object})'
>>    acceptedHttpMethods: ['POST', 'GET', 'PUT', 'DELETE']
>>    appendExceedingArguments: TRUE
>>    defaults:
>>      '@package': 'Vender.Package'
>>      '@controller': 'Rest'
>>      '@format': 'json'
>> -
>>    name : 'API'
>>    uriPattern: 'api'
>>    acceptedHttpMethods: ['GET']
>>    appendExceedingArguments: TRUE
>>    defaults:
>>      '@package': 'Vendor.Package'
>>      '@controller': 'Rest'
>>      '@format': 'json'
>>      '@action': 'help'
>>
>> ----------------
>>
>
>  When I write the /api address i get the help function and the returned
>> JSON
>> but when i add the "@action" like this
>>
>> http://host.tld/api/team
>>
>> I get this error in return
>>
>> No controller could be resolved [...]
>>
>
> First a few hints:
>
> * It helps if you give your routes unique names - The system log
> (Data/Logs/System_<Context>.**log) will refer to them.
> * The HTTP Request method filter is just called "httpMethods", not
> "acceptedHttpMethods" (see [1])
> * Only use "appendExceedingArguments" and optional route parts if you
> really need them, they make debugging slightly harder
>
> Now to your issue:
>
> For optional route parts you'll have to define a default (see [2]).
>
> HTH
>
>
> [1] http://docs.typo3.org/flow/**TYPO3FlowDocumentation/**
> TheDefinitiveGuide/PartIII/**Routing.html#request-methods<http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/Routing.html#request-methods>
> [2] http://docs.typo3.org/flow/**TYPO3FlowDocumentation/**
> TheDefinitiveGuide/PartIII/**Routing.html#optional-route-**parts<http://docs.typo3.org/flow/TYPO3FlowDocumentation/TheDefinitiveGuide/PartIII/Routing.html#optional-route-parts>
>
> --
> Bastian Waidelich
> --
> Core Developer Team
>
> TYPO3 .... inspiring people to share!
> Get involved: typo3.org
>
> ______________________________**_________________
> Flow mailing list
> Flow at lists.typo3.org
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/flow<http://lists.typo3.org/cgi-bin/mailman/listinfo/flow>
>


More information about the Flow mailing list