polyfony-inc/polyfony

Implement a Router::getBaseUrl() method

Opened this issue · 0 comments

We sometime (rarely) need to build URLs manually, such as for serving one static file that doesn't have a route associated.
For example a Picture placeholder which doesn't have an actual route declated.

Router::getBaseUrl() would be a public method returning {method}://{domain}

An alternative solution would be the ability to declare routes for static files.
ex

Router::get(
    '/images/placeholder.png', // url
    '/Assets/Img/Shared/placeholder.png', // destination
    'image-placeholder' // route name
);

The absence of / and @ in the destination (Bundle/Controller@Action) could allow to deduce that it's a static file.

but that could bypass Nginx caching policy for URLs starting with /Assets/