package middleware

import "net/http"

// Chain applies middlewares to a handler in order.
// The first middleware is the outermost wrapper.
func Chain(handler http.Handler, middlewares ...func(http.Handler) http.Handler) http.Handler {
	for i := len(middlewares) - 1; i >= 0; i-- {
		handler = middlewares[i](handler)
	}
	return handler
}
