-
Notifications
You must be signed in to change notification settings - Fork 0
/
builder.go
26 lines (21 loc) · 978 Bytes
/
builder.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package client
import (
"github.com/orchestd/dependencybundler/interfaces/configuration"
"net/http"
)
// HTTPHandler is just an alias to http.RoundTriper.RoundTrip function
type HTTPHandler func(*http.Request) (*http.Response, error)
// HTTPClientInterceptor is a user defined function that can alter a request before it's sent
// and/or alter a response before it's returned to the caller
type HTTPClientInterceptor func(*http.Request, HTTPHandler) (*http.Response, error)
// HTTPClientBuilder is a builder interface to build http.Client with interceptors
type HTTPClientBuilder interface {
SetConfig(conf configuration.Config) HTTPClientBuilder
AddInterceptors(...HTTPClientInterceptor) HTTPClientBuilder
WithPreconfiguredClient(*http.Client) HTTPClientBuilder
Build() (HttpClient, error)
}
// NewHTTPClientBuilder REST HTTP builder
//
// Useful when you want to create several *http.Client with different options
type NewHTTPClientBuilder func() HTTPClientBuilder