Grokking Advanced Go
0% completed
Middleware
Middleware is a function that takes an HTTP handler and returns a new handler with extra behavior around the original. The new handler can run code before the original, run code after it, or skip it. In Go, this definition fits one function type: func(http.Handler) http.Handler.
The input and the output have the same type, and that is the advantage of this signature. A wrapped handler is still an http.Handler, so it can be wrapped again, and each wrapper is called a layer. The inner handler contains no code that depends on how many layers exist
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%