Re: [auraphp] Aura.Router + Zend Diactoros aren't giving me any attributes in the request, am I doing something wrong?

61 views
Skip to first unread message

Hari K T

unread,
Mar 5, 2016, 12:38:26 AM3/5/16
to aur...@googlegroups.com
Hi,

Given the URL `http://media.jonnys-place.app/img/logo.svg` I want to grab "logo" and "svg" I'm using Aura.Router for the routing and Zend Diactoros to serve the request/response. However the following code isn't working for me:

    $map->
       
get('media.img', '/img/{file}{format}', function (ServerRequestInterface $request, ResponseInterface $response) use ( $mediaController )
       
{
            $file
= $request->getAttribute("file");
            $format
= $request->getAttribute("format");
            $response
->getBody()->write("You asked for file '{$file}' of format '{$format}'");
           
return $response;
       
})->
        host
("media.jonnys-place.{tld}")->
        tokens
([
           
'file' => '\w+',
           
'format' => '(\.[^/]+)?',
       
])
   
;

Result is You asked for file '' of format '' Even using $request->getAttributes() returns an empty array. I'm sure I'm following the instructions correctly.

It looks you are not ;-) .
 
What's going on?

Did you defined the withAttribute to set the attributes to request ?

Thank you

Hari KT

Jonny Axehandle

unread,
Mar 5, 2016, 2:06:18 PM3/5/16
to The Aura Project for PHP
On Saturday, March 5, 2016 at 12:38:26 AM UTC-5, Hari K T wrote:
Did you defined the withAttribute to set the attributes to request ?

Thank you

Hari KT

Yep that was it! Thanks!
Reply all
Reply to author
Forward
0 new messages