title: Force Gitlab to retry webhooks on failure with Go
body: <p>I want to watch for every events in a Gitlab project and store them in an external service. For this, I use Gitlab Webhooks. I made a little local HTTP server in Go that listens for Gitlab's POSTs and forward them to an external service. Hooks contains every information I needed so it seems that this architecture is fine: </p>
  
  <blockquote>
  <pre><code>Gitlab &gt; HTTPServer &gt; External Service.
  </code></pre>
  </blockquote>
  
  <p>My problem is when the external service is down, I cannot manage to make Gitlab retry the failed requests. As the <a href="https://docs.gitlab.com/ee/user/project/integrations/webhooks.html#webhook-endpoint-tips" rel="nofollow noreferrer">documentation</a> says: </p>
  
  <ul>
  <li><em>GitLab ignores the HTTP status code returned by your endpoint.</em></li>
  <li><em>Your endpoint should ALWAYS return a valid HTTP response. If you do not do this then GitLab will think the hook failed and retry it.</em></li>
  </ul>
  
  <p>It is very surprising that Gitlab does not have a proper way to ask for a webhook retry. I have to explicitly return an invalid http response. Moreover, I cannot find an API endpoint to list all failed webhooks and ask for resend.</p>
  
  <p>Question: How to explicitly return an invalid HTTP response with the standard "net/http" library in order to force Gitlab to retry Webhooks?</p>