Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing, and http verb (or http method) #1110

Closed
roberto-butti opened this issue Mar 3, 2012 · 6 comments
Closed

Routing, and http verb (or http method) #1110

roberto-butti opened this issue Mar 3, 2012 · 6 comments

Comments

@roberto-butti
Copy link

I'm going to implement a new rounting functionality.
In application/config/routes.php the developers can define routing rules such as:

$route['product/:num'] = "catalog/product_lookup";

This rule has 1 input: the URL and 1 output the action in a specific controller.
I would like to introduce the HTTP method in the routing rules for example:

$route['test'] = array();
$route['test']["GET"] = "welcome/gethttp";
$route['test']["POST"] = "welcome/posthttp";

For backward compatibility, the rules:

$route['test'] = "welcome/index";

is still valid and the system/core/Router.php will check if the rules is a string i follow the normal behaviour, if is array i will check also the HTTP method.

What do you think about tihs?

@roberto-butti
Copy link
Author

I'm checking the code of Router.php.
Maybe the best way to define a verb keyword in the key of the array $route like this (or something else)

$route[':GET:/test'] = "welcome/gethttp";
$route[':POST:/test'] = "welcome/gethttp";

I don't know. I'm going on study the code of Router.php and later i will be able to take a decision (maybe) :)

@roberto-butti
Copy link
Author

ok, there is my pull request. The patch is here: roberto-butti@4d788ce

@narfbg
Copy link
Contributor

narfbg commented Oct 31, 2012

In the meantime (or unless nothing similar to this is implemented), #1636 might help you in creating any type of route.

@alexbilbie
Copy link
Contributor

I've always preferred how @philsturgeon's REST server library did it.

Rather than messing around with routes you just suffix your controller method with _post, _put or _delete

@pveyes
Copy link
Contributor

pveyes commented Oct 31, 2013

I tried implementing HTTP verb in routing using array index, here's my pull request

@narfbg
Copy link
Contributor

narfbg commented Nov 12, 2013

Implemented via #2712.

@narfbg narfbg closed this as completed Nov 12, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants