title: Generating Hypermedia links in a Web API
body: <p>I'm curious to know how others have dealt with the issue of generating hypermedia links for their web APIs? Specifically, I'm using ASP.NET Web API, and am torn between having operations return hypermedia-related types, or returning the resource itself, and having the hypermedia stuff happen later in the pipeline.
  That is, do people tend to do things like:</p>
  
  <pre><code>public Resource&lt;Order&gt; GetOrder(int id) { 
    return new Resource&lt;Order&gt;() {
        Content = new Order(),
        Links = new LinkCollection&lt;Order&gt;() { new AddOrderLink(), new UpdateOrderLink()}
    }
  </code></pre>
  
  <p>Or something more like</p>
  
  <pre><code>public Order GetOrder(int id) { return new Order(); }
  </code></pre>
  
  <p>And then add hypermedia links inside an HttpOperationHandler or custom formatter or something?</p>
  
  <p>If the approach is more like #2, how do you know what links to generate? Just have some standard set of links that get generated for all Order objects? Attributes decorating various operations in OrdersController?</p>