URL Templating: Difference between revisions
(Created page with "It is sometimes useful to allow a client to construct a URL. This is frequently done using out of band information but that has the disadvantage that the server is no long...") |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
== Example == | == Example == | ||
Let's say we want to tell a custom client for this wiki where it can find a page with a given title. We can do this by sending the following [[link header]]: | Let's say we want to tell a custom client for this wiki where it can find a page with a given title. We can do this by sending the following [[Link Header | link header]]: | ||
Link: <https://docs.delftsolutions.nl/index.php?title={title}>; rel=search; templated=true | Link: <https://docs.delftsolutions.nl/index.php?title={title}>; rel="search"; templated="true" | ||
In our [[Media Types | media type documentation]] we then tell the client that they have fill in the ''title'' variable and can do a GET on the resulting page. If we later decide to use pretty urls we can simply change the server to return the following link header: | In our [[Media Types | media type documentation]] we then tell the client that they have fill in the ''title'' variable and can do a GET on the resulting page. If we later decide to use pretty urls we can simply change the server to return the following link header: | ||
Link: <https://docs.delftsolutions.nl/{title}>; rel=search; templated=true | Link: <https://docs.delftsolutions.nl/{title}>; rel="search"; templated="true" | ||
Clients will then automatically use the new URL structure without needing an update. | Clients will then automatically use the new URL structure without needing an update. | ||
Line 14: | Line 14: | ||
== RFC == | == RFC == | ||
More information about URL templating can be found in [https://tools.ietf.org/html/rfc6570 RFC 6570]. | More information about URL templating can be found in [https://tools.ietf.org/html/rfc6570 RFC 6570]. | ||
[[Category: RFCs]] |
Latest revision as of 09:20, 3 December 2020
It is sometimes useful to allow a client to construct a URL. This is frequently done using out of band information but that has the disadvantage that the server is no longer in control of the URL structure. To solve this we can use templated URLs.
Example
Let's say we want to tell a custom client for this wiki where it can find a page with a given title. We can do this by sending the following link header:
Link: <https://docs.delftsolutions.nl/index.php?title={title}>; rel="search"; templated="true"
In our media type documentation we then tell the client that they have fill in the title variable and can do a GET on the resulting page. If we later decide to use pretty urls we can simply change the server to return the following link header:
Link: <https://docs.delftsolutions.nl/{title}>; rel="search"; templated="true"
Clients will then automatically use the new URL structure without needing an update.
RFC
More information about URL templating can be found in RFC 6570.