<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE rfc [
  <!ENTITY nbsp    "&#160;">
  <!ENTITY zwsp   "&#8203;">
  <!ENTITY nbhy   "&#8209;">
  <!ENTITY wj     "&#8288;">
]>
<?xml-stylesheet type="text/xsl" href="rfc2629.xslt" ?>
<!-- generated by https://github.com/cabo/kramdown-rfc version 1.6.17 (Ruby 3.1.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpapi-link-template-01" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.15.3 -->
  <front>
    <title abbrev="Link-Template">The Link-Template HTTP Header Field</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-httpapi-link-template-01"/>
    <author initials="M." surname="Nottingham" fullname="Mark Nottingham">
      <organization/>
      <address>
        <postal>
          <postalLine>Prahran</postalLine>
          <postalLine>Australia</postalLine>
        </postal>
        <email>mnot@mnot.net</email>
        <uri>https://www.mnot.net/</uri>
      </address>
    </author>
    <date year="2022" month="December" day="30"/>
    <area>Applications and Real-Time</area>
    <workgroup>Building Blocks for HTTP APIs</workgroup>
    <keyword>link relation</keyword>
    <abstract>
      <t>This specification defines the Link-Template HTTP header field, providing a means for describing the structure of a link between two resources, so that new links can be generated.</t>
    </abstract>
    <note removeInRFC="true">
      <name>About This Document</name>
      <t>
        The latest revision of this draft can be found at <eref target="https://ietf-wg-httpapi.github.io/link-template/draft-ietf-httpapi-link-template.html"/>.
        Status information for this document may be found at <eref target="https://datatracker.ietf.org/doc/draft-ietf-httpapi-link-template/"/>.
      </t>
      <t>
        Discussion of this document takes place on the
        Building Blocks for HTTP APIs Working Group mailing list (<eref target="mailto:httpapi@ietf.org"/>),
        which is archived at <eref target="https://mailarchive.ietf.org/arch/browse/httpapi/"/>.
        Subscribe at <eref target="https://www.ietf.org/mailman/listinfo/httpapi/"/>.
      </t>
      <t>Source for this draft and an issue tracker can be found at
        <eref target="https://github.com/ietf-wg-httpapi/link-template"/>.</t>
    </note>
  </front>
  <middle>
    <section anchor="introduction">
      <name>Introduction</name>
      <t><xref target="URI-TEMPLATE"/> defines a syntax for templates that, when expanded using a set of variables, results in a URI <xref target="URI"/>.</t>
      <t>This specification defines a HTTP header field <xref target="HTTP"/> for conveying templates for links in the headers of a HTTP message. It is complimentary to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, which carries links directly.</t>
      <section anchor="notational-conventions">
        <name>Notational Conventions</name>
        <t>The key words "<bcp14>MUST</bcp14>", "<bcp14>MUST NOT</bcp14>", "<bcp14>REQUIRED</bcp14>", "<bcp14>SHALL</bcp14>", "<bcp14>SHALL
NOT</bcp14>", "<bcp14>SHOULD</bcp14>", "<bcp14>SHOULD NOT</bcp14>", "<bcp14>RECOMMENDED</bcp14>", "<bcp14>NOT RECOMMENDED</bcp14>",
"<bcp14>MAY</bcp14>", and "<bcp14>OPTIONAL</bcp14>" in this document are to be interpreted as
described in BCP 14 <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when, they
appear in all capitals, as shown here.</t>
        <t>This specification uses the following terms from <xref target="STRUCTURED-FIELDS"/>: List, String, Parameter.</t>
      </section>
    </section>
    <section anchor="the-link-template-header-field">
      <name>The Link-Template Header Field</name>
      <t>The Link-Template header field is a Structured Field <xref target="STRUCTURED-FIELDS"/> that serializes one or more links into HTTP message metadata. It is semantically equivalent to the Link header field defined in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>, except that it uses URI Templates <xref target="URI-TEMPLATE"/> to convey the structure of links.</t>
      <t>Its value is a List of Strings. Each String is a URI Template, and Parameters on it carry associated metadata.</t>
      <t>For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: "/{username}"; rel="https://example.org/rel/user"
]]></sourcecode>
      <t>indicates that a resource with the relation type "https://example.org/rel/user" can be found by interpolating the "username" variable into the template given.</t>
      <t>The target for the link (as defined in <xref section="2" sectionFormat="of" target="WEB-LINKING"/>) is the result of expanding the URI Template <xref target="URI-TEMPLATE"/> (being converted to an absolute URI after expansion, if necessary).</t>
      <t>The context, relation type and target attributes for the link are determined as defined for the Link header field in <xref section="3" sectionFormat="of" target="WEB-LINKING"/>.</t>
      <t>Parameters on a templated link have identical semantics to those of a Link header field. This includes (but is not limited to) the use of the "rel" parameter to convey the relation type, the "anchor" parameter to modify the context IRI, and so on. Parameter values <bcp14>MUST</bcp14> be Strings.</t>
      <t>Likewise, the requirements for parameters on templated links are the same as those for a Link header field.</t>
      <t>However, the "anchor" parameter <bcp14>MAY</bcp14> contain a URI Template. For example:</t>
      <sourcecode type="http-message"><![CDATA[
Link-Template: </books/{book_id}/author>;
               rel="author" anchor="#{book_id}"
]]></sourcecode>
      <t>Here, the link to the author for a particular book in a list of books can be found by following the link template.</t>
      <t>This specification defines additional semantics for the "var-base" parameter on templated links; see below.</t>
      <section anchor="the-var-base-parameter">
        <name>The 'var-base' parameter</name>
        <t>When a templated link has a 'var-base' parameter, its value conveys a URI-reference that is used as a base URI for the variable names in the URI template. This allows template variables to be globally identified, rather than specific to the context of use.</t>
        <t>Dereferencing the URI for a particular variable might lead to more information about the syntax or semantics of that variable; specification of particular formats for this information is out of scope for this document.</t>
        <t>To determine the URI for a given variable, the value given is used as a base URI in reference resolution (as specified in <xref target="URI"/>). If the resulting URI is still relative, the context of the link is used as the base URI in a further resolution; see <xref target="WEB-LINKING"/>.</t>
        <t>For example:</t>
        <sourcecode type="http-message"><![CDATA[
Link-Template: "/widgets/{widget_id}"
               rel="https://example.org/rel/widget";
               var-base="https://example.org/vars/"
]]></sourcecode>
        <t>indicates that a resource with the relation type "https://example.org/rel/widget" can be found by interpolating the "https://example.org/vars/widget_id" variable into the template given.</t>
        <t>If the current context of the message that the header appears within is "https://example.org/", the same information could be conveyed by this header field:</t>
        <sourcecode type="http-message"><![CDATA[
Link-Template: "/widgets/{widget_id}";
               rel="https://example.org/rel/widget";
               var-base="/vars/"
]]></sourcecode>
      </section>
    </section>
    <section anchor="security-considerations">
      <name>Security Considerations</name>
      <t>The security consideration for the Link header field in <xref target="WEB-LINKING"/> and those for URI Templates <xref target="URI-TEMPLATE"/> both apply.</t>
    </section>
    <section anchor="iana-considerations">
      <name>IANA Considerations</name>
      <t>This specification enters the "Link-Template" into the Hypertext Transfer Protocol (HTTP) Field Name Registry.</t>
      <artwork><![CDATA[
Field Name: Link-Template
Status: permanent
Specification document: [this document]
]]></artwork>
    </section>
  </middle>
  <back>
    <references>
      <name>Normative References</name>
      <reference anchor="HTTP">
        <front>
          <title>HTTP Semantics</title>
          <author fullname="Roy T. Fielding" initials="R. T." surname="Fielding">
            <organization>Adobe</organization>
          </author>
          <author fullname="Mark Nottingham" initials="M." surname="Nottingham">
            <organization>Fastly</organization>
          </author>
          <author fullname="Julian Reschke" initials="J." surname="Reschke">
            <organization>greenbytes GmbH</organization>
          </author>
          <date day="12" month="September" year="2021"/>
          <abstract>
            <t>The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for distributed, collaborative, hypertext information systems. This document describes the overall architecture of HTTP, establishes common terminology, and defines aspects of the protocol that are shared by all versions. In this definition are core protocol elements, extensibility mechanisms, and the "http" and "https" Uniform Resource Identifier (URI) schemes.

 This document updates RFC 3864 and obsoletes RFCs 2818, 7231, 7232, 7233, 7235, 7538, 7615, 7694, and portions of 7230.
            </t>
          </abstract>
        </front>
        <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-semantics-19"/>
      </reference>
      <reference anchor="URI-TEMPLATE">
        <front>
          <title>URI Template</title>
          <author fullname="J. Gregorio" initials="J." surname="Gregorio">
            <organization/>
          </author>
          <author fullname="R. Fielding" initials="R." surname="Fielding">
            <organization/>
          </author>
          <author fullname="M. Hadley" initials="M." surname="Hadley">
            <organization/>
          </author>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham">
            <organization/>
          </author>
          <author fullname="D. Orchard" initials="D." surname="Orchard">
            <organization/>
          </author>
          <date month="March" year="2012"/>
          <abstract>
            <t>A URI Template is a compact sequence of characters for describing a range of Uniform Resource Identifiers through variable expansion. This specification defines the URI Template syntax and the process for expanding a URI Template into a URI reference, along with guidelines for the use of URI Templates on the Internet.   [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="6570"/>
        <seriesInfo name="DOI" value="10.17487/RFC6570"/>
      </reference>
      <reference anchor="URI">
        <front>
          <title>Uniform Resource Identifier (URI): Generic Syntax</title>
          <author fullname="T. Berners-Lee" initials="T." surname="Berners-Lee">
            <organization/>
          </author>
          <author fullname="R. Fielding" initials="R." surname="Fielding">
            <organization/>
          </author>
          <author fullname="L. Masinter" initials="L." surname="Masinter">
            <organization/>
          </author>
          <date month="January" year="2005"/>
          <abstract>
            <t>A Uniform Resource Identifier (URI) is a compact sequence of characters that identifies an abstract or physical resource.  This specification defines the generic URI syntax and a process for resolving URI references that might be in relative form, along with guidelines and security considerations for the use of URIs on the Internet.  The URI syntax defines a grammar that is a superset of all valid URIs, allowing an implementation to parse the common components of a URI reference without knowing the scheme-specific requirements of every possible identifier.  This specification does not define a generative grammar for URIs; that task is performed by the individual specifications of each URI scheme.  [STANDARDS-TRACK]</t>
          </abstract>
        </front>
        <seriesInfo name="STD" value="66"/>
        <seriesInfo name="RFC" value="3986"/>
        <seriesInfo name="DOI" value="10.17487/RFC3986"/>
      </reference>
      <reference anchor="WEB-LINKING">
        <front>
          <title>Web Linking</title>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham">
            <organization/>
          </author>
          <date month="October" year="2017"/>
          <abstract>
            <t>This specification defines a model for the relationships between resources on the Web ("links") and the type of those relationships ("link relation types").</t>
            <t>It also defines the serialisation of such links in HTTP headers with the Link header field.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8288"/>
        <seriesInfo name="DOI" value="10.17487/RFC8288"/>
      </reference>
      <reference anchor="STRUCTURED-FIELDS">
        <front>
          <title>Structured Field Values for HTTP</title>
          <author fullname="M. Nottingham" initials="M." surname="Nottingham">
            <organization/>
          </author>
          <author fullname="P-H. Kamp" initials="P-H." surname="Kamp">
            <organization/>
          </author>
          <date month="February" year="2021"/>
          <abstract>
            <t>This document describes a set of data types and associated algorithms that are intended to make it easier and safer to define and handle HTTP header and trailer fields, known as "Structured Fields", "Structured Headers", or "Structured Trailers". It is intended for use by specifications of new HTTP fields that wish to use a common syntax that is more restrictive than traditional HTTP field values.</t>
          </abstract>
        </front>
        <seriesInfo name="RFC" value="8941"/>
        <seriesInfo name="DOI" value="10.17487/RFC8941"/>
      </reference>
      <reference anchor="RFC2119">
        <front>
          <title>Key words for use in RFCs to Indicate Requirement Levels</title>
          <author fullname="S. Bradner" initials="S." surname="Bradner">
            <organization/>
          </author>
          <date month="March" year="1997"/>
          <abstract>
            <t>In many standards track documents several words are used to signify the requirements in the specification.  These words are often capitalized. This document defines these words as they should be interpreted in IETF documents.  This document specifies an Internet Best Current Practices for the Internet Community, and requests discussion and suggestions for improvements.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="2119"/>
        <seriesInfo name="DOI" value="10.17487/RFC2119"/>
      </reference>
      <reference anchor="RFC8174">
        <front>
          <title>Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words</title>
          <author fullname="B. Leiba" initials="B." surname="Leiba">
            <organization/>
          </author>
          <date month="May" year="2017"/>
          <abstract>
            <t>RFC 2119 specifies common key words that may be used in protocol  specifications.  This document aims to reduce the ambiguity by clarifying that only UPPERCASE usage of the key words have the  defined special meanings.</t>
          </abstract>
        </front>
        <seriesInfo name="BCP" value="14"/>
        <seriesInfo name="RFC" value="8174"/>
        <seriesInfo name="DOI" value="10.17487/RFC8174"/>
      </reference>
    </references>
  </back>
  <!-- ##markdown-source:
H4sIAAAAAAAAA61Y23LjNhJ951dgNQ8Zb4mS7ZlNPJokFY3tiVXr29pyTaVS
qS2QhCSUKYILgJIVl+Zb9lv2y/Y0QFKkpLkku36whEsD3ae7TzcUhmFgpU3F
gHXGM8EuZfYYjsU8T7kV7GI8vmUXgidC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