Skip to content
This repository was archived by the owner on Apr 11, 2019. It is now read-only.

Latest commit

 

History

History
24 lines (18 loc) · 1.57 KB

README.md

File metadata and controls

24 lines (18 loc) · 1.57 KB

Context-Aware HTTP Handlers

GoDoc Build Status (Linux) Build status (Windows) license GoReportCard

Deprecated

Go 1.7 includes the context package in the standard library, and the net/http package includes a Context in the http.Request structure. If you are targeting Go 1.7 and later, there is significantly less need for a package like httpctx.

Description

The httpctx package provides a convenient way to handle HTTP requests using "context-aware" handler functions. Context-aware handlers are different from the standard http.Handler in two important ways:

  1. They accept an additional parameter of the (almost) standard type context.Context (golang.org/x/net/context); and
  2. They return an error result.

The httpctx package also implements a simple middleware chaining mechanism. The idea for this comes from Justinas Stankevičius and his alice package. (https://github.com/justinas/alice).

For usage examples, refer to the GoDoc documentation.