Skip to content

Refactor to use pluggable http.Handler middlewares

Andrew Newdigate requested to merge an-use-middleware-handlers into master

Required for !158 (closed)

This is a precursor to switching out the access logger for the the LabKit access logger.

This change refactors the pages app away from tightly coupled flow control to a series of http.Handler middlewares.

Each middleware is of the form func(http.Handler) http.Handler.

The buildPipeline function is then used to couple these middlewares together, for the given configuration, and whether the pipeline will be used to handle proxy or HTTP traffic.

This approach is more maintainable, as middlewares can be added or removed independently of one another.

As a next step, the logging middleware will be replaced with the logkit logging middleware.

Edited by Andrew Newdigate

Merge request reports