Documentation ¶
Index ¶
- Variables
- func ErrorFunc(expectStatusCode int) func(*http.Response) error
- func IsValidPathSegmentName(name string) []string
- func NewRESTClient(transport Transport, method string) *restfulClient
- func OnRetryCondition(resp *http.Response, err error) bool
- type Handler
- type JsonRequest
- type JsonResponse
- type Logger
- type MockRoundTripper
- type MockRoundTripperMockRecorder
- type RESTClient
- type Requester
- type Response
- type Transport
Constants ¶
This section is empty.
Variables ¶
var DefaultTransport = NewTransporter(JsonRequest{}, http.DefaultTransport, JsonResponse{})
DefaultTransport 默认配置的传输层实现
var NameMayNotBe = []string{".", ".."}
NameMayNotBe specifies strings that cannot be used as names specified as path segments (like the REST API or etcd store)
var NameMayNotContain = []string{"/", "%"}
NameMayNotContain specifies substrings that cannot be used in names specified as path segments (like the REST API or etcd store)
Functions ¶
func IsValidPathSegmentName ¶
IsValidPathSegmentName validates the name can be safely encoded as a path segment
func NewRESTClient ¶
NewRESTClient start to reqest
Types ¶
type Handler ¶
type Handler interface { Endpoint(endpoint string) Handler Resource(resource string) Handler To() Transport }
func NewHandler ¶
func NewHandler() Handler
type JsonRequest ¶
type JsonRequest struct { }
type JsonResponse ¶
type JsonResponse struct { }
type Logger ¶
type MockRoundTripper ¶
type MockRoundTripper struct {
// contains filtered or unexported fields
}
MockRoundTripper is a mock of RoundTripper interface.
func NewMockRoundTripper ¶
func NewMockRoundTripper(ctrl *gomock.Controller) *MockRoundTripper
NewMockRoundTripper creates a new mock instance.
func (*MockRoundTripper) EXPECT ¶
func (m *MockRoundTripper) EXPECT() *MockRoundTripperMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockRoundTripperMockRecorder ¶
type MockRoundTripperMockRecorder struct {
// contains filtered or unexported fields
}
MockRoundTripperMockRecorder is the mock recorder for MockBuildProcess.
func (*MockRoundTripperMockRecorder) RoundTrip ¶
func (mr *MockRoundTripperMockRecorder) RoundTrip(req interface{}) *gomock.Call
RoundTrip indicates an expected call of RoundTrip.
type RESTClient ¶
type RESTClient interface { // Endpoints add endpoints to the client Endpoints(endpoint string) RESTClient Prefix(segments ...string) RESTClient Suffix(segments ...string) RESTClient Resource(resource string) RESTClient Name(resourceName string) RESTClient SubResource(subResources ...string) RESTClient Query(key string, value ...string) RESTClient Querys(value interface{}) RESTClient Headers(header http.Header) RESTClient Header(key string, values ...string) RESTClient Body(obj interface{}) RESTClient Retry(backoff backoff.BackOff, shouldRetryFunc func(*http.Response, error) bool) RESTClient Do(ctx context.Context, result interface{}, opts ...func(*http.Response) error) error DoNop(ctx context.Context, opts ...func(*http.Response) error) error DoRaw(ctx context.Context) ([]byte, error) Stream(ctx context.Context) (io.ReadCloser, error) }
func Delete ¶
func Delete() RESTClient
func Get ¶
func Get() RESTClient
func Patch ¶
func Patch() RESTClient
func Post ¶
func Post() RESTClient
func Put ¶
func Put() RESTClient
type Transport ¶
type Transport interface { http.RoundTripper WithRequest(requester Requester) Transport WithClient(roundTripper http.RoundTripper) Transport WithResponse(response Response) Transport Request() Requester Response() Response Client() http.RoundTripper Method(string) RESTClient }
func NewTransporter ¶
func NewTransporter(req Requester, roundTripper http.RoundTripper, resp Response) Transport