URL Templating: Difference between revisions
m (Fix missing quotes) |
No edit summary |
||
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" |
Revision as of 09:15, 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.