Documentation
¶
Index ¶
- type Client
- type ClientContentConfig
- type Interface
- type Request
- func (r *Request) AbsPath(segments ...string) *Request
- func (r *Request) Body(obj interface{}) *Request
- func (r *Request) Do(ctx context.Context) Result
- func (r *Request) DoRaw(ctx context.Context) ([]byte, error)
- func (r *Request) Param(paramName, s string) *Request
- func (r *Request) RequestURI(uri string) *Request
- func (r *Request) SetHeader(key string, values ...string) *Request
- func (r *Request) Timeout(d time.Duration) *Request
- func (r *Request) URL() *url.URL
- func (r *Request) Verb(verb string) *Request
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { // Set specific behavior of the client. If not set http.DefaultClient will be used. Client *http.Client // contains filtered or unexported fields }
simple rest client , inspired by k8s client-go restClient
func NewRESTClient ¶
func NewRESTClient(baseURL *url.URL, config ClientContentConfig, client *http.Client) (*Client, error)
NewRESTClient creates a new RESTClient. This client performs generic REST functions such as Get, Put, Post, and Delete on specified paths.
func RESTClientFor ¶
func RESTClientFor(config *restclient.Config) (*Client, error)
RESTClientFor new simple rest client for config
type ClientContentConfig ¶
type ClientContentConfig struct { // AcceptContentTypes specifies the types the client will accept and is optional. // If not set, ContentType will be used to define the Accept header AcceptContentTypes string // ContentType specifies the wire format used to communicate with the server. // This value will be set as the Accept header on requests made to the server if // AcceptContentTypes is not set, and as the default content type on any object // sent to the server. If not set, "application/json" is used. ContentType string }
type Interface ¶
type Interface interface { Verb(verb string) *Request Post() *Request Put() *Request Get() *Request Delete() *Request }
Interface rest client interface
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
func NewRequest ¶
NewRequest creates a new request helper object for accessing runtime.Objects on a server.
func (*Request) AbsPath ¶
AbsPath overwrites an existing path with the segments provided. Trailing slashes are preserved when a single segment is passed.
func (*Request) Do ¶
Do formats and executes the request. Returns a Result object for easy response processing.
Error type:
- If the server responds with a status: *errors.StatusError or *errors.UnexpectedObjectError
- http.Client.Do errors are returned directly.
func (*Request) RequestURI ¶
RequestURI overwrites existing path and parameters with the value of the provided server relative URI.
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
Result contains the result of calling Request.Do().
func (Result) Error ¶
Error returns the error executing the request, nil if no error occurred. If the returned object is of type Status and has Status != StatusSuccess, the additional information in Status will be used to enrich the error. See the Request.Do() comment for what errors you might get.
func (Result) StatusCode ¶
StatusCode returns the HTTP status code of the request. (Only valid if no error was returned.)