In Go, testing HTTP handlers is more work than testing regular functions. Inputs must be wrapped in HTTP requests, and responses are written to http.ResponseWriter, rather than being returned directly. To make matters worse, handlers expect server-side requests, while it’s easy to mistakenly construct client-side requests. You’d almost give up on testing your handlers altogether. Please don’t. This article will discuss how we can use httptest to safely test HTTP handlers.