Request helper
- Posted by dlib on March 29th, 2008 filed in Code examples
The previous post covers it but I’ll complement it with this post. I wrote a request helper which some may find useful. It’s fairly simple, you can retrieve all kinds of information on the current request.
request::accepts_xhtml();// test to see if the browser accepts xhtml or not (IE) request::accepts_xml(); request::accepts_rss(); request::accepts_atom(); request::is_post(); //is request a post request request::is_ajax(); //test if it's an ajax request, most js-frameworks support this request::is_delete(); //delete request request::is_get(); request::is_put(); request::accepts(); //returns array of all accepted content types
March 30th, 2008 at 6:25 am
Very nice, and i find the code rather clean
March 31st, 2008 at 7:44 am
Hello, it would be nice to have a “messages” helper, i had one in codeigniter :
$this->messages->add(’Error in your password’,'error’);
then on the page the error is displayed.
using flashvariables.
March 31st, 2008 at 11:46 am
A message helper isn’t that hard to do. You could even do a messages:add_redirect(’error in password’,'user/login’); method. So you combine the redirect into the helper.
April 2nd, 2008 at 10:53 am
[...] and XML side by side with no special API controller. Using a new module for Kohana PHP written by Maarten Van Vliet called request_Core(), the controller will inspect the incoming request and automatically determine [...]