func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
	// Return ahead of time if there aren't any middlewares for the chain
	if len(middlewares) == 0 {
		return endpoint
	}

	// Wrap the end handler with the middleware chain
	h := middlewares[len(middlewares)-1](endpoint)
	for i := len(middlewares) - 2; i >= 0; i-- {
		h = middlewares[i](h)
	}

	return h
}
func chain(middlewares []func(http.Handler) http.Handler, endpoint http.Handler) http.Handler {
	
	if len(middlewares) == 0 {
		return endpoint
	}

	
	h := middlewares[len(middlewares)-1](endpoint)
	for i := len(middlewares) - 2; i >= 0; i-- {
		h = middlewares[i](h)
	}

	return h
}
func chain ( middlewares [ ] func ( http . Handler ) http . Handler , endpoint http . Handler ) http . Handler { // Return ahead of time if there aren't any middlewares for the chain if len ( middlewares ) == 0 { return endpoint } // Wrap the end handler with the middleware chain h := middlewares [ len ( middlewares ) - 1 ] ( endpoint ) for i := len ( middlewares ) - 2 ; i >= 0 ; i -- { h = middlewares [ i ] ( h ) } return h }
// chain builds a http.Handler composed of an inline middleware stack and endpoint
// handler in the order they are passed.
chain builds a http . Handler composed of an inline middleware stack and endpoint handler in the order they are passed .