URI Template variable containing a path?
-
14-03-2021 - |
Question
I have a question about URI template variables.
I need to manage an URI with the form:
http://netlocation:port/application_path/{variable}
the variable can be a path itself, i.e. something like
this/variable/is/a/path
so that the complete URI appears to be
http://netlocation:port/application_path/this/variable/is/a/path
how can I manage that?
Solution
Use the "+" operator in order to avoid escaping the "/" character:
http://netlocation:port/application_path/{+foo}
You can try on URI Template Parser Online
OTHER TIPS
You could use query parameters and just encode the path variable in the standard way:
http://netlocation:port/application_path?path=%2Fthis%2Fvariable%2Fisapath
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow