Skip to content

Endpoint with Verb (::verb) and parameter #4324

Closed Answered by ivan-tymoshenko
fredrikj31 asked this question in Q&A
Discussion options

You must be logged in to vote

@fredrikj31 If you just want a path containing a colon without declaring a parameter, use a double colon. For example, /name::customVerb will be interpreted as /name:customVerb.

But your case is different. As I understand, you want to have a parameter + static suffix. find-my-way, which is Fastify router, supports . and - chars as markers that the param name is ended. So you can natively define routes like that:
localhost:3000/v1/cars/:carId-start
localhost:3000/v1/cars/:carId.stop

If you don't want to use '.' or '-' in your path, you should use the regexp route.
localhost:3000/v1/cars/:carId(.*)::start
localhost:3000/v1/cars/:carId(.*)::stop
depends on your request url format.

I checked …

Replies: 4 comments 9 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@fredrikj31
Comment options

Comment options

You must be logged in to vote
7 replies
@fredrikj31
Comment options

@ivan-tymoshenko
Comment options

@ivan-tymoshenko
Comment options

@ivan-tymoshenko
Comment options

@fredrikj31
Comment options

Answer selected by fredrikj31
Comment options

You must be logged in to vote
1 reply
@ivan-tymoshenko
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants