go-http.json 2.9 KB

123456
  1. {
  2. "html": "<div class=\"section\" id=\"installation\">\n<h2>Installation</h2>\n<p>Simply install <code class=\"docutils literal\"><span class=\"pre\">raven-go</span></code> through <code class=\"docutils literal\"><span class=\"pre\">go</span> <span class=\"pre\">get</span></code>:</p>\n<div class=\"highlight-python\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span>$ go get github.com/getsentry/raven-go\n</pre></div>\n</div>\n</div>\n\n\n<div class=\"section\" id=\"setup\">\n<h2>Setup</h2>\n<p>Make sure that you&#8217;ve set configured <code class=\"docutils literal\"><span class=\"pre\">raven</span></code> with your DSN, typically inside the <code class=\"docutils literal\"><span class=\"pre\">init()</span></code>\nin your <code class=\"docutils literal\"><span class=\"pre\">main</span></code> package is a good place.</p>\n<div class=\"highlight-go\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">package</span> <span style=\"color: #111111\">main</span>\n\n<span style=\"color: #2eb0f7\">import</span> <span style=\"color: #e8535a\">&quot;github.com/getsentry/raven-go&quot;</span>\n\n<span style=\"color: #2eb0f7\">func</span> <span style=\"color: #111111\">init()</span> <span style=\"color: #111111\">{</span>\n <span style=\"color: #111111\">raven.SetDSN(</span><span style=\"color: #e8535a\">&quot;___DSN___&quot;</span><span style=\"color: #111111\">)</span>\n<span style=\"color: #111111\">}</span>\n</pre></div>\n</div>\n<p>If you don&#8217;t call <code class=\"docutils literal\"><span class=\"pre\">SetDSN</span></code>, we will attempt to read it from your environment under the\n<code class=\"docutils literal\"><span class=\"pre\">SENTRY_DSN</span></code> environment variable.</p>\n<p>Next, we need to wrap our <code class=\"docutils literal\"><span class=\"pre\">http.Handler</span></code> with our <code class=\"docutils literal\"><span class=\"pre\">RecoveryHandler</span></code>:</p>\n<div class=\"highlight-go\"><div class=\"highlight\" style=\"background: #ffffff\"><pre style=\"line-height: 125%\"><span></span><span style=\"color: #2eb0f7\">func</span> <span style=\"color: #111111\">root(w</span> <span style=\"color: #111111\">http.ResponseWriter,</span> <span style=\"color: #111111\">r</span> <span style=\"color: #4b4f5c\">*</span><span style=\"color: #111111\">http.Request)</span> <span style=\"color: #111111\">{</span>\n <span style=\"color: #34c08b; font-style: italic\">// ... do stuff</span>\n<span style=\"color: #111111\">}</span>\n<span style=\"color: #111111\">http.HandleFunc(</span><span style=\"color: #e8535a\">&quot;/&quot;</span><span style=\"color: #111111\">,</span> <span style=\"color: #111111\">raven.RecoveryHandler(root))</span>\n</pre></div>\n</div>\n</div>\n",
  3. "link": null,
  4. "id": "go-http",
  5. "name": "net/http"
  6. }