Skip to content

Routing

Michal Tuček edited this page Feb 15, 2021 · 2 revisions

Paths example:

  • ''
  • '/'
  • '/posts'
  • '/posts/{id}'
  • '/posts/{id:id}'
  • '/posts[/{id:id}]'
  • '/gallery/{galleryID:id}/image/{imageID:id}'
  • '/gallery/{galleryID:id}[/image/{imageID:id}]'
  • '/stock/{stockID:id}[/supplier/{supplierID:id}[/product/{productID:id}]]'

When the route like this occurs

'/gallery/{galleryID:id}[/image/{imageID:id}]'

we should generate two routes starting from the last optional one to first mandatory

  1. '/gallery/{galleryID:id}/image/{imageID:id}'
  2. '/gallery/{galleryID:id}'

for the second case, we still want imageID to be set with the null value.


If $match starts with { and ends with } then remove those signs and split string by : where first element of the returned array will be the name of the param and the second element will be its regex pattern to be matched. If the array has only one element the :any pattern will be selected.

Clone this wiki locally