echo icon indicating copy to clipboard operation
echo copied to clipboard

[issue-2557] Add :from-:to range route formats

Open ProgrammingMuffin opened this issue 1 year ago • 8 comments

Implements this feature (https://github.com/labstack/echo/issues/2557)

Adds :from-:to route.

example /flights/:from-:to

image image

ProgrammingMuffin avatar Dec 17 '23 07:12 ProgrammingMuffin

This is little bit too simple take for implementing this feature. I would say that the requirement we are talking is allowing multiple parameters per route segment where segment is string part between / (slashes). Searching for param end to be / or - is little bit too restricted. Probably using syntax "/{month}-{day}-{year}" like Chi uses would be better.

p.s. using new special characters in route paths like { and } (or whatever character pair is selected) potentially breaks small number of users applications.

aldas avatar Dec 17 '23 14:12 aldas

@aldas Thank you for your comment.

the / delimiter was already present and I don't think we should change that.

If I understood correctly, the restriction here is that users cannot use - in a parameter name like :user-name. Is that correct?

ProgrammingMuffin avatar Dec 17 '23 15:12 ProgrammingMuffin

If I understood correctly, the restriction here is that users cannot use - in a parameter name like :user-name. Is that correct?

No, using only - is too restricting.

the / delimiter was already present and I don't think we should change that.

Sorry, I did not word this clearly. What I meant is that in addition to :param we could support {param} syntax and in that case we can have anything between two params like {file}.{ext}. As long there is something between that we can distinguish as separator.

aldas avatar Dec 17 '23 18:12 aldas

@aldas

image image

ProgrammingMuffin avatar Dec 18 '23 13:12 ProgrammingMuffin

Hi @aldas , I am just following up on this PR to see if there are any further changes to be made. Thank you for your time!

ProgrammingMuffin avatar Dec 28 '23 15:12 ProgrammingMuffin

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (584cb85) 92.89% compared to head (d2b378c) 92.90%. Report is 4 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2560      +/-   ##
==========================================
+ Coverage   92.89%   92.90%   +0.01%     
==========================================
  Files          39       39              
  Lines        4658     4668      +10     
==========================================
+ Hits         4327     4337      +10     
  Misses        240      240              
  Partials       91       91              

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Dec 28 '23 17:12 codecov[bot]

@aldas Thank you for triggering the code coverage action. Looking forward to further updates on this PR.

ProgrammingMuffin avatar Feb 26 '24 18:02 ProgrammingMuffin

@aldas Hi, can this PR be merged? The {} placeholder format is very good. Some frameworks in other languages ​​also use this approach For example: https://laravel.com/docs/11.x/routing#required-parameters

OneSeven avatar Jul 22 '24 06:07 OneSeven