title: How should I unit test middleware packages with gorilla context
body: <p>I have this net/http server setup with several middleware in a chain and I can't find examples on how I should test these...</p>
  
  <p>I am using basic net/http with the gorilla/mux router and one Handle looks somewhat like this:</p>
  
  <pre><code>r.Handle("/documents", addCors(checkAPIKey(getDocuments(sendJSON)))).Methods("GET")
  </code></pre>
  
  <p>In these I aggregate some data and supply them via Gorilla Context context.Set methods.</p>
  
  <p>Usually I test my http functions with httptest, and I hope to do it with these as well but I can't figure out how and I am curious as to what is the best way. Should I test each middleware seperately? Should I prefill the appropriate context values then when they are needed? Can I test this entire chain at once so I can just check desired states on input?</p>