Documentation ¶
Index ¶
- type ResourceReader
- func (r *ResourceReader) AddHeader(key, value string) *ResourceReader
- func (r *ResourceReader) Body(body io.Reader) *ResourceReader
- func (r *ResourceReader) Bytes(data []byte) *ResourceReader
- func (r *ResourceReader) Do() *Response
- func (r *ResourceReader) Err() error
- func (r *ResourceReader) SetHeader(key, value string) *ResourceReader
- func (r *ResourceReader) SetVars(variables *vars.Variables) *ResourceReader
- func (r *ResourceReader) String(val string) *ResourceReader
- func (r *ResourceReader) WithContext(ctx context.Context) *ResourceReader
- func (r *ResourceReader) WithHeaders(h http.Header) *ResourceReader
- 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() *Response
- 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) WithContext(ctx context.Context) *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 GetWithContextVars ¶ added in v0.4.1
GetWithContextVars uses context ctx and session variables to initiate a "GET" operation for the specified resource
func GetWithVars ¶ added in v0.3.0
func GetWithVars(url string, variables *vars.Variables) *ResourceReader
GetWithVars uses session vars to initiate a "GET" operation
func (*ResourceReader) AddHeader ¶ added in v0.4.1
func (r *ResourceReader) AddHeader(key, value string) *ResourceReader
AddHeader convenience method to add request header
func (*ResourceReader) Body ¶
func (r *ResourceReader) Body(body io.Reader) *ResourceReader
RequestBody sets GET request content as io.Reader
func (*ResourceReader) Bytes ¶
func (r *ResourceReader) Bytes(data []byte) *ResourceReader
RequestBytes sets GET request data as byte slice
func (*ResourceReader) Do ¶
func (r *ResourceReader) Do() *Response
Do is a terminal method that actually retrieves the HTTP resource from the server. It returns a gexe/http/*Response instance that can be used to access the result.
func (*ResourceReader) SetHeader ¶ added in v0.4.1
func (r *ResourceReader) SetHeader(key, value string) *ResourceReader
SetHeader convenience method to set a specific header
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(val string) *ResourceReader
RequestString sets GET request data as string
func (*ResourceReader) WithContext ¶ added in v0.4.1
func (r *ResourceReader) WithContext(ctx context.Context) *ResourceReader
WithContext sets the context for the HTTP request
func (*ResourceReader) WithHeaders ¶ added in v0.4.1
func (r *ResourceReader) WithHeaders(h http.Header) *ResourceReader
WithHeaders sets all HTTP headers for GET request
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 provides types and methods used to post resource data to an HTTP server
func Post ¶
func Post(resource string) *ResourceWriter
Post starts an HTTP "POST" operation using the provided URL.
func PostWithContextVars ¶ added in v0.4.1
func PostWithContextVars(ctx context.Context, resource string, variables *vars.Variables) *ResourceWriter
PostWithContextVars uses the specified context ctx and session variable to start an HTTP "POST" operation
func PostWithVars ¶ added in v0.3.0
func PostWithVars(resource string, variables *vars.Variables) *ResourceWriter
PostWithVars uses session variables to start an HTTP "POST" operation
func (*ResourceWriter) AddHeader ¶
func (w *ResourceWriter) AddHeader(key, value string) *ResourceWriter
AddHeader is a convenience method to add a single header for the post operation
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() *Response
Do is a terminal method that actually posts the HTTP request to the server. It returns a gexe/http/*Response instance that can be used to access post result.
func (*ResourceWriter) Err ¶
func (w *ResourceWriter) Err() error
Err returns the last error generated by the ResourceWriter
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 for the post operation
func (*ResourceWriter) SetVars ¶ added in v0.3.0
func (w *ResourceWriter) SetVars(variables *vars.Variables) *ResourceWriter
SetVars sets gexe session variables to be used by the post operation
func (*ResourceWriter) String ¶
func (w *ResourceWriter) String(val string) *ResourceWriter
String posts the string value content to the server and returns a gexe/http/*Response
func (*ResourceWriter) WithContext ¶ added in v0.4.1
func (w *ResourceWriter) WithContext(ctx context.Context) *ResourceWriter
WithContext sets the context to be used for the HTTP request
func (*ResourceWriter) WithHeaders ¶
func (w *ResourceWriter) WithHeaders(h http.Header) *ResourceWriter
WithHeaders sets all HTTP headers to be used by 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 used 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