File size: 281 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
package main
import (
"net/http"
"sync"
)
type RR struct {
h []http.Handler
n int
mx sync.Mutex
}
func (r *RR) ServeHTTP(w http.ResponseWriter, req *http.Request) {
r.mx.Lock()
handler := r.h[r.n]
r.n = (r.n + 1) % len(r.h)
r.mx.Unlock()
handler.ServeHTTP(w, req)
}
|