Re: [Specifications] Relative Template URIs (#208)

> Please feel free to deliberate more. I just don't want to use any unnecessary quick moves to claim low hanging fruits while breaking something we can't see now.

Okay, let's take step back. Please refer to the [section 5.1 of the URI RFC3986](https://tools.ietf.org/html/rfc3986#section-5.1). It defines four sources of a Base URI:

5.1.1.  Base URI Embedded in Content
5.1.2.  Base URI from the Encapsulating Entity
5.1.3.  URI used to retrieve the entity  
5.1.4.  Default Base URI (application-dependent)

I propose to follow this as it is an established standard that we can refer to for guidance and disambiguation. It appears to also be a fair match for your proposal.

5.1.1 is out of scope, because Hydra client is already operating on the parsed RDF graph so any media-type annotations (`@base` in turtle or JSON-LD) are out of reach (unless... read to the end).

Here's my take

```
Given a triple :Resource :Link :IriTemplate, when :Link is a hydra:TemplatedLink and its hydra:template is a relative reference, then the client MUST establish a Base URI according to the section 5.1 of the RFC 3986:

1. if the :Resource is a named resource, its identifier serves as the Base URI
2. if not then the URI of the requested resource is the Base URI according to section 5.1.3 of the aforementioned RFC 3986
3. if the requested resource URI is not known, then an application specific, default Base URI is used as defined in section 5.1.4 of RFC 3986 

With the Base URI established, the client SHOULD resolve the URI using the method described in section 5.2 of RFC before sending a server request.
```

Two things to notice:

1. I am back to only considering the direct link relation between `:Resource` and `:IriTemplate` above. If `:Resource` is a blank node then the next step should be taken
2. In the last step I used `SHOULD` because for example in the case of browser's `fetch` the browser will automatically apply the default Base URI when a request is made using a relative reference. Otherwise the client library such as Alcaeus or Heracles.X would need a Base URI setting.

> We could also consider some additional hints to the client on which algorithm to use (leaving current behavior as default)

I would not. Please let's stick to the saying that "Everything should be made as simple as possible, but not simpler"

-- 
GitHub Notification of comment by tpluscode
Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/208#issuecomment-616364837 using your GitHub account

Received on Monday, 20 April 2020 07:31:27 UTC