traefik/middlewares/cbreaker.go
Emile Vauge 0cbe34eef3
Move to containous/oxy, remove websocket specific support
Signed-off-by: Emile Vauge <emile@vauge.com>
2016-03-15 23:42:52 +01:00

22 lines
626 B
Go

package middlewares
import (
"net/http"
"github.com/containous/oxy/cbreaker"
)
// CircuitBreaker holds the oxy circuit breaker.
type CircuitBreaker struct {
circuitBreaker *cbreaker.CircuitBreaker
}
// NewCircuitBreaker returns a new CircuitBreaker.
func NewCircuitBreaker(next http.Handler, expression string, options ...cbreaker.CircuitBreakerOption) *CircuitBreaker {
circuitBreaker, _ := cbreaker.New(next, expression, options...)
return &CircuitBreaker{circuitBreaker}
}
func (cb *CircuitBreaker) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
cb.circuitBreaker.ServeHTTP(rw, r)
}