DASPRiD / Dash

Flexible PSR-7 compliant HTTP router
BSD 2-Clause "Simplified" License
29 stars 9 forks source link

Prepend #52

Closed bakura10 closed 9 years ago

bakura10 commented 9 years ago

Hi,

I don't remember if this is coded in Dash, but in ZF2, I always struggle very very hard with prepending a route to an existing route. You ahve to create "prototype", and used "chain_routes", which is very confusign. For Dash, I suggest a mapping like that:

return 'routes' => [
    'my-hostname' => ['api.myapp.com'],

    'users' => ['prepend' => 'my-hostname']
]

And boom.

DASPRiD commented 9 years ago

Route prepending is not required in in Dash anymore. You can simple add e.g. the hostname or secure property to the existing route via overriding.

bakura10 commented 9 years ago

Nope this is not a solution. In my app for instance I have different host names based on my environment, so I write it once and then prepend it to my routes, so I don't have to duplicatebtheblogic of detecting environment and choosing environment. Makes sense ?

DASPRiD commented 9 years ago

You can do the exact same with config overrides, e.g. in local.config.php.

bakura10 commented 9 years ago

But I don't have any routes in those files. The config is scattered across module config files.

DASPRiD commented 9 years ago

The reason why I didn't re-implement route-prepending is because it was basically a total mess. Also there's no such thing as a hostname route. If you don't have a single parent route which you can easily override, you could always use application-level constants or environment variables.