Endpoint with Verb (::verb) and parameter #4324
-
Hi. I was wondering if it's possible to have an endpoint like this:
Where in Fastify I think it would be structured like this:
I can't figure out a way to structure the endpoint url. Is it possible to have an endpoint with Fastify which supports this kind og behavior? Best regards Fredrik Johansen |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 9 replies
-
@ivan-tymoshenko do you remember if we support escaping the |
Beta Was this translation helpful? Give feedback.
-
@fredrikj31 Can you give me an example of an incoming url, please? |
Beta Was this translation helpful? Give feedback.
-
@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: If you don't want to use '.' or '-' in your path, you should use the regexp route. I checked if it works, and it doesn't. There is a bug. It doesn't escape the double colon in a multi-parametric node. |
Beta Was this translation helpful? Give feedback.
-
I think you'll find using |
Beta Was this translation helpful? Give feedback.
@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 …