what’s middleware
tags: learning go programming
content
- a
Handlerin a Go http server is a type that implementsServeHTTPmethod go-http-handler - a middleware is something that wraps a handler in another handler
- it means, a middleware function takes in a handler as arguments, and returns another handler
- a middleware’s signature:
func MyMiddleware(next http.Handler) http.Handler- go’s middleware is essentially a wrapping pattern
- it’s kinda similar to python’s decorator