16 lines
309 B
Go
16 lines
309 B
Go
|
package main
|
||
|
|
||
|
import "net/http"
|
||
|
|
||
|
// Adapter is an HTTP middleware
|
||
|
type Adapter func(http.Handler) http.Handler
|
||
|
|
||
|
// Adapt applies adapters to an HTTP handler function
|
||
|
func Adapt(h http.Handler, adapters ...Adapter) http.Handler {
|
||
|
for i := len(adapters) - 1; i >= 0; i-- {
|
||
|
h = adapters[i](h)
|
||
|
}
|
||
|
|
||
|
return h
|
||
|
}
|