Welcome Guest, Not a member yet? Register   Sign In
The Request class rework
#7

(This post was last modified: 12-09-2021, 09:32 PM by iRedds.)

1. Routes depend on the HTTP method.
PHP Code:
$request->get('resource''Controller::getRequest')
$request->post('resource''Controller::postRequest'

2. Even if the route listens to multiple HTTP methods, the controller still has to separate the logic for different methods.
PHP Code:
$request->match(['get''post'], 'resource''Controller::request')
//... 
if ($this->request->getMethod() == 'post') { }
else { }
/* By the way, why are there no isPost/isGet/isMethodName methods yet? */ 

3. The IncomingRequest class already has a getVar() method, which is independent of the HTTP method.

Basically, you always want data sent by a specific HTTP method.
For example, you won't call getDelete() if there was a GET or POST or PUT request.

The only time to qualify a request method is any HTTP method other than GET + a query string.
Reply


Messages In This Thread
The Request class rework - by iRedds - 12-07-2021, 11:53 PM
RE: The Request class rework - by includebeer - 12-08-2021, 04:37 PM
RE: The Request class rework - by iRedds - 12-08-2021, 08:21 PM
RE: The Request class rework - by kenjis - 12-09-2021, 07:10 PM
RE: The Request class rework - by kenjis - 12-08-2021, 05:09 PM
RE: The Request class rework - by includebeer - 12-09-2021, 05:28 PM
RE: The Request class rework - by iRedds - 12-09-2021, 09:32 PM
RE: The Request class rework - by kenjis - 12-10-2021, 02:39 AM
RE: The Request class rework - by iRedds - 12-10-2021, 03:04 AM
RE: The Request class rework - by kenjis - 12-10-2021, 04:18 AM



Theme © iAndrew 2016 - Forum software by © MyBB