jakartaee / servlet

Jakarta Servlet
https://eclipse.org/ee4j/servlet
Other
263 stars 85 forks source link

addLinkHeader #674

Open gregw opened 2 months ago

gregw commented 2 months ago

From #672:

To assist with early hints, should we add a response method like:

     void addLinkHeader(String uri, String relationship, String... attributeValuePairs);

So this could be used like:

    response.addLinkHeader("http://example.com/TheBook/chapter2", "previous", "title", "previous chapter"
    response.addLinkHeader("/", "http://example.net/foo");
    response.addLinkHeader("/terms", "copyright", "anchor","#foo");

and would generate the following headers:

   Link: <http://example.com/TheBook/chapter2>; rel="previous"; title="previous chapter"
   Link: </>; rel="http://example.net/foo"
   Link: </terms>; rel="copyright"; anchor="#foo"
gregw commented 2 months ago

The use of varargs for attribute value pairs is not the best, but less verbose than Map.of(...)