I was recently asked, how I would implement a http middleware scheme in golang.
As is probably fairly evident by my online writing, I am a person of simplicity
and always opt for the simple solution, with the least magic. Below is my
middleware solution:
The above 7 line middleware implementation is very flexible and when you think
of a middleware as functions that call other functions you can do some pretty
interesting things. This is all possible due to the fact that functions are
first class citizens in golang. Here is a sample implementation.