anandkunal / ToroPHP

Toro is a PHP router for developing RESTful web applications and APIs.
http://toroweb.org
MIT License
1.17k stars 173 forks source link

Added Toro::hashandlerfor function to check if a route is served or not #60

Closed small1 closed 11 years ago

small1 commented 11 years ago

We needed a good way of checking if a route is served or not. So that we can serve different routes depending on user access.

Sample code:

function GenHREF($href, $caption) { / * custom href that knows about toro-handlers * * result if foo refers to a toro-handler : * bar * result if foo doesn't refer to a toro-handler : * bar / if (Toro::hashandlerfor($href)) return "$caption"; else return $caption; }

martinbean commented 11 years ago

Can you check your commits and make the formatting match the rest of the file please, mainly lining up indentation and using the same number of spaces. I’d also make method names like hashandlerfor() camel-cased (hasHandlerFor).