Documentation ¶
Index ¶
- type ResourceReader
- type ResourceWriter
- func (w *ResourceWriter) AddHeader(key, value string) *ResourceWriter
- func (w *ResourceWriter) Body(val io.Reader) *ResourceWriter
- func (w *ResourceWriter) Bytes(val []byte) *ResourceWriter
- func (w *ResourceWriter) Do() *ResourceWriter
- func (w *ResourceWriter) Err() error
- func (w *ResourceWriter) FormData(val map[string][]string) *ResourceWriter
- func (w *ResourceWriter) SetHeader(key, value string) *ResourceWriter
- func (w *ResourceWriter) String(val string) *ResourceWriter
- func (w *ResourceWriter) WithHeaders(h http.Header) *ResourceWriter
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceReader ¶
type ResourceReader struct {
// contains filtered or unexported fields
}
ResourceReader provides types and methods to read content of resources from a server using HTTP
func Get ¶
func Get(url string) *ResourceReader
Get initiates a "GET" operation for the specified resource
func (*ResourceReader) Body ¶
func (r *ResourceReader) Body() io.ReadCloser
Body returns an io.ReadCloser to stream the server response. NOTE: ensure to close the stream when finished.
func (*ResourceReader) Bytes ¶
func (b *ResourceReader) Bytes() []byte
Bytes returns the server response as a []byte
func (*ResourceReader) Do ¶
func (r *ResourceReader) Do() *ResourceReader
Do invokes the client.Get to "GET" the content from server
func (*ResourceReader) Response ¶
func (r *ResourceReader) Response() *Response
Response returns the server's response info
func (*ResourceReader) String ¶
func (b *ResourceReader) String() string
String returns the server response as a string
type ResourceWriter ¶
type ResourceWriter struct {
// contains filtered or unexported fields
}
ResourceWriter represents types and methods used to post resource data to an HTTP server
func Post ¶
func Post(resource string) *ResourceWriter
Post starts a "POST" HTTP operation to the provided resource.
func (*ResourceWriter) AddHeader ¶
func (w *ResourceWriter) AddHeader(key, value string) *ResourceWriter
AddHeader is a convenience method to add a single header
func (*ResourceWriter) Body ¶
func (w *ResourceWriter) Body(val io.Reader) *ResourceWriter
Body provides an io reader to stream content to the server
func (*ResourceWriter) Bytes ¶
func (w *ResourceWriter) Bytes(val []byte) *ResourceWriter
Bytes posts the slice of bytes as content to the server
func (*ResourceWriter) Do ¶
func (w *ResourceWriter) Do() *ResourceWriter
Do is a terminal method that completes the post request of data to the HTTP server.
func (*ResourceWriter) Err ¶
func (w *ResourceWriter) Err() error
Err returns the last known error for the post operation
func (*ResourceWriter) FormData ¶
func (w *ResourceWriter) FormData(val map[string][]string) *ResourceWriter
FormData posts form-encoded data as content to the server
func (*ResourceWriter) SetHeader ¶
func (w *ResourceWriter) SetHeader(key, value string) *ResourceWriter
SetHeader is a convenience method to sets a specific header
func (*ResourceWriter) String ¶
func (w *ResourceWriter) String(val string) *ResourceWriter
String posts the string value as content to the server
func (*ResourceWriter) WithHeaders ¶
func (w *ResourceWriter) WithHeaders(h http.Header) *ResourceWriter
WithHeaders sets all headers for the post operation
type Response ¶
type Response struct {
// contains filtered or unexported fields
}
Response stores high level metadata and responses from HTTP request results
func (*Response) Body ¶
func (res *Response) Body() io.ReadCloser
Body is io.ReadCloser stream to the content from serve. NOTE: ensure to call Close() if used directly.
func (*Response) Status ¶
Status returns the standard lib http.Response.Status value from the server
func (*Response) StatusCode ¶
StatusCode returns the standard lib http.Response.StatusCode value from the server