Uh oh!
There was an error while loading. Please reload this page.
Request: added withUrl() - #69
Conversation
enumag
commented
Aug 9, 2015
Can you show an example of a test where you need this? I never needed anything like it, instead it would be really benefitial for my tests if Request would not be a service (and Response as well for that matter). Also I certainly wouldn't like this method in the IRequest interface. |
fprochazka
commented
Aug 9, 2015
@JanTvrdik I like the idea, doing this every time is tedious. |
JanTvrdik
commented
Aug 9, 2015
Feel free to join the relevant discussion.
Sorry, I have a really bad memory. I found the code I have written (6 days ago) and the class DevRouter implementsApplication\IRouter
{
// *.signaly.cz -> *.signaly.l // *.signaly.cz -> localhost/signaly/www/*publicfunction__construct($fromMask, $toMask, Application\IRouter$innerRouter)
{
$this->fromMask = $fromMask;
$this->toMask = $toMask;
$this->innerRouter = $innerRouter;
}
publicfunctionmatch(Nette\Http\IRequest$httpRequest)
{
$fixedUrl = $this->transformIn($httpRequest->url);
$fixedHttpRequest = $httpRequest->withUrl($fixedUrl); // <-- THIS IS THE LINEreturn$this->innerRouter->match($fixedHttpRequest);
}
publicfunctionconstructUrl(Request$appRequest, Nette\Http\Url$refUrl)
{
$url = $this->innerRouter->constructUrl($appRequest, $refUrl);
$fixedUrl = $this->transformOut($url);
return$fixedUrl;
}
} |
enumag
commented
Aug 9, 2015
In my opinion you should just write a static helper method |
1dc599c to
f35d20fCompare7981e33 to
3fb64f5Compareb9f06ea to
4f6d6c9Compare2ff2f22 to
40175d7Compareb031216 to
9979093Compare7f12fde to
9791354Compare51f373c to
69af026Compare87fefb5 to
9590f91Compare56c2641 to
544d9e6Comparecaa05a6 to
708b922Compare
It's often useful (e.g. in tests) to modify URL inside httpRequest. Doing this is really annoying because Request has lot of constructor parameters. The naming (
with*) is based on PSR-7.What do you think about this idea? Tests are currently missing.