<?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.22 (Ruby 3.1.3) -->
<rfc xmlns:xi="http://www.w3.org/2001/XInclude" ipr="trust200902" docName="draft-ietf-httpapi-link-template-02" category="std" consensus="true" tocInclude="true" sortRefs="true" symRefs="true" version="3">
  <!-- xml2rfc v2v3 conversion 3.16.0 -->
  <front>
    <title abbrev="Link-Template">The Link-Template HTTP Header Field</title>
    <seriesInfo name="Internet-Draft" value="draft-ietf-httpapi-link-template-02"/>
    <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="2023" month="February" day="01"/>
    <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 expanding 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>Implementations <bcp14>MUST</bcp14> support all levels of template defined by <xref target="URI-TEMPLATE"/> in both the rel and anchor parameters.</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 expanding 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:
H4sIAAAAAAAAA61Y23IbNxJ9n6/A0g+xtjikJXsTm05SkSU5Yq1uK1HlSqVS
W5gZkERpOJgFMKQYFf0t+y37ZX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