Documentation ¶
Overview ¶
Package middleware provides middlewares for htt.Client as RoundTripperHandler
Index ¶
- func BasicAuth(user, passwd string) func(http.RoundTripper) http.RoundTripper
- func Header(key, value string) func(http.RoundTripper) http.RoundTripper
- func JSON(next http.RoundTripper) http.RoundTripper
- func MaxConcurrent(max int) func(http.RoundTripper) http.RoundTripper
- type CircuitBreakerFunc
- type CircuitBreakerSvc
- type RepeaterSvc
- type RoundTripperFunc
- type RoundTripperHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(user, passwd string) func(http.RoundTripper) http.RoundTripper
BasicAuth middleware adds basic auth to request
func Header ¶
func Header(key, value string) func(http.RoundTripper) http.RoundTripper
Header middleware adds a header to request
func JSON ¶
func JSON(next http.RoundTripper) http.RoundTripper
JSON sets Content-Type and Accept headers to json
func MaxConcurrent ¶
func MaxConcurrent(max int) func(http.RoundTripper) http.RoundTripper
MaxConcurrent middleware limits the total concurrency for a given requester
Types ¶
type CircuitBreakerFunc ¶
CircuitBreakerFunc is an adapter to allow the use of ordinary functions as CircuitBreakerSvc.
func (CircuitBreakerFunc) Execute ¶
func (c CircuitBreakerFunc) Execute(req func() (interface{}, error)) (interface{}, error)
Execute CircuitBreakerFunc
type CircuitBreakerSvc ¶
CircuitBreakerSvc is an interface wrapping any function to send a request with circuit breaker. can be used with github.com/sony/gobreaker or any similar implementations
type RepeaterSvc ¶
RepeaterSvc defines repeater interface
type RoundTripperFunc ¶
RoundTripperFunc is a functional adapter for RoundTripperHandler
type RoundTripperHandler ¶
type RoundTripperHandler func(http.RoundTripper) http.RoundTripper
RoundTripperHandler is a type for middleware handler
func CircuitBreaker ¶
func CircuitBreaker(svc CircuitBreakerSvc) RoundTripperHandler
CircuitBreaker middleware injects external CircuitBreakerSvc into the call chain
func Repeater ¶
func Repeater(repeater RepeaterSvc, failOnCodes ...int) RoundTripperHandler
Repeater sets middleware with provided RepeaterSvc to retry failed requests