Skip to content

Instantly share code, notes, and snippets.

@wchan2
wchan2 / README.md
Last active May 8, 2017 08:43
GoLang HTTP Middleware

GoLang HTTP Middleware

Utility functions that can compose http.Handlers and http.HandlerFuncs to create middlewares. Note that when the status code is written to the http.ResponseWriter, the response is immediately flushed regardless whether a handlers further down the middleware chain is writing to the http.ResponseWriter.

Use cases

Some use cases where this may be useful are listed below. Please feel free to comment to add to the list.

  • Requiring authentication before allowing access to the main handler
  • Proxy to different services depending on application logic or migrations