Getting the request type for a Controller Route::register()

Permalink 1 user found helpful
Hello all,

I need to declare a route for each type of request (GET, POST, PUT, DELETE) in the file /application/bootstrap/app.php

Something like:
<?
    //One route for GET, one for POST, one for PUT and one for DELETE
    Route::register(
        '/animal/{favorite}',
        'Application\Controller\Animal::setFavorite'
    );


Does anyone can help me with this?

Thank you.

titanve
 
titanve replied on at Permalink Reply
titanve
Hello,

I come with the answer:

Just change the /application/bootstrap/app.php Route::register for:
Route::register(
'/animal/{favorite}',
'Application\Controller\Animal::setFavorite',null,
array(), // requirements
array(), // options
'', // host
array(), // schemes
array('GET')
);

OR
Route::register(
'/animal/{favorite}',
'Application\Controller\Animal::setFavoritePost',null,
array(), // requirements
array(), // options
'', // host
array(), // schemes
array('POST')
);