title: REST Check if resource exists, how to handle on server side?
body: <p>how to handle resource checking on server side?
  For example, my api looks like:</p>
  
  <pre class="lang-java prettyprint-override"><code>/books/{id}
  </code></pre>
  
  <p>After googling i found, that i should use HEAD method to check, if resource exists. 
  <a href="https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html" rel="noreferrer">https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html</a></p>
  
  <p>I know, that i can use GET endpoint and use HEAD method to fetch information about resource and server does not return body in this case.</p>
  
  <p>But what should i do on server side? 
  I have two options.</p>
  
  <ol>
  <li><p>One endpoint marked as GET. I this endpoint i can use GET method to fetch data and HEAD to check if resource is available.</p></li>
  <li><p>Two endpoints. One marked as GET, second as HEAD.</p></li>
  </ol>
  
  <p>Why i'm considering second solution? 
  Let's assume, that GET request fetch some data from database and process them in some way which takes some time, eg. 10 ms</p>
  
  <p>But what i actually need is only to check if data exists in database. So i can run query like</p>
  
  
  
  <pre><code>select count(*) from BOOK where id = :id
  </code></pre>
  
  <p>and immediately return status 200 if result of query is equal to 1. In this case i don't need to process data so i get a faster response time.</p>
  
  <p>But... resource in REST is a object which is transmitted via HTTP, so maybe i should do processing data but not return them when i use HEAD method?</p>
  
  <p>Thanks in advance for your answer!</p>