Skip to content
This repository has been archived by the owner on Jan 21, 2020. It is now read-only.

Regex in zend-expressive-zendrouter #22

Open
mano87 opened this issue Feb 27, 2017 · 2 comments
Open

Regex in zend-expressive-zendrouter #22

mano87 opened this issue Feb 27, 2017 · 2 comments

Comments

@mano87
Copy link

mano87 commented Feb 27, 2017

Hello,
we will migrate our ZF2 MVC Application to ZF3 Expressive. For some functions we use Regex to build the routes. When can I use Regex in zend-expressive-zendrouter?

For example:

'vcalendar' => [
  'type' => 'regex',
  'options' => [
    'regex' => '/vcalendar/(?<room>[0-9]+)(\.(?<format>(html|ics)))?',
    'defaults' => [
      'action' => 'vcalendar',
      'format' => 'ics'
    ],
    'spec' => '/vcalendar/%room%.%format%',
  ],
],
@weierophinney
Copy link
Member

You can't, at least not using the Expressive API for attaching routes to middleware, due to a need to keep the API compatible between all routing implementations. In particular, we found that HTTP method negotiation, while supported directly in other routing implementations, was something we had to "hack" around to make work with zend-router; we ended up injecting a method route as a child route on the primary route to make it happen.

We could potentially support this by allowing you to provide the route type via route options (which would be handled in the ZendRouter::injectRoute() method); if anybody would like to try their hand at this, I'd welcome a pull request.

@weierophinney
Copy link
Member

This repository has been closed and moved to mezzio/mezzio-laminasrouter; a new issue has been opened at mezzio/mezzio-laminasrouter#1.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants