Documentation ¶
Index ¶
- type ResourceReader
- func (r *ResourceReader) Body() io.ReadCloser
- func (r *ResourceReader) Bytes() []byte
- func (r *ResourceReader) Do() *Response
- func (r *ResourceReader) Err() error
- func (r *ResourceReader) SetVars(variables *vars.Variables) *ResourceReader
- func (r *ResourceReader) String() string
- func (r *ResourceReader) WithTimeout(to time.Duration) *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) SetVars(variables *vars.Variables) *ResourceWriter
- func (w *ResourceWriter) String(val string) *ResourceWriter
- func (w *ResourceWriter) WithHeaders(h http.Header) *ResourceWriter
- func (w *ResourceWriter) WithTimeout(to time.Duration) *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 GetWithVars ¶ added in v0.3.0
func GetWithVars(url string, variables *vars.Variables) *ResourceReader
Get initiates a "GET" operation and sets session variables
func (*ResourceReader) Body ¶
func (r *ResourceReader) Body() io.ReadCloser
Body returns the server response body (as io.ReadCloser). It is a shorthand for ResourceReader().Do().Body() NOTE: ensure to close the stream when finished.
func (*ResourceReader) Bytes ¶
func (r *ResourceReader) Bytes() []byte
Bytes returns the server response as a []byte This is a shorthad for ResourceReader.Do().Bytes()
func (*ResourceReader) Do ¶
func (r *ResourceReader) Do() *Response
Do invokes the client.Get to "GET" the content from server Use Response.Err() to access server response errors
func (*ResourceReader) SetVars ¶ added in v0.3.0
func (r *ResourceReader) SetVars(variables *vars.Variables) *ResourceReader
SetVars sets session variables for ResourceReader
func (*ResourceReader) String ¶
func (r *ResourceReader) String() string
String returns the server response as a string. It is a shorthad for ResourceReader.Do().String()
func (*ResourceReader) WithTimeout ¶ added in v0.3.0
func (r *ResourceReader) WithTimeout(to time.Duration) *ResourceReader
WithTimeout sets the HTTP reader's timeout
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 PostWithVars ¶ added in v0.3.0
func PostWithVars(resource string, variables *vars.Variables) *ResourceWriter
PostWithVars sets up a "POST" operation and sets its session variables
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) SetVars ¶ added in v0.3.0
func (w *ResourceWriter) SetVars(variables *vars.Variables) *ResourceWriter
SetVars sets session variables for the ResourceWriter
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
func (*ResourceWriter) WithTimeout ¶ added in v0.3.0
func (w *ResourceWriter) WithTimeout(to time.Duration) *ResourceWriter
WithTimeout sets the HTTP client's timeout
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