Documentation ¶
Index ¶
- func ValidateAPIVersion(v string) error
- func ValidateURL(u string) error
- type Method
- type Requester
- type Response
- func (r *Response) Body() ([]byte, error)
- func (r *Response) Close() error
- func (r *Response) Error() (*response.Error, error)
- func (r *Response) IsError() bool
- func (r *Response) IsStream() bool
- func (r *Response) ReadJSON(js interface{}) error
- func (r *Response) ReadStreamJSON() (<-chan interface{}, error)
- func (r *Response) StreamError() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidateAPIVersion ¶
ValidateAPIVersion checks if the given API version is valid.
func ValidateURL ¶
ValidateURL validates if the given URL is valid for the SensorBee API server.
Types ¶
type Requester ¶
type Requester struct {
// contains filtered or unexported fields
}
Requester sends raw HTTP requests to the server. Requester doesn't have a state, so it can be used concurrently.
func NewRequester ¶
NewRequester creates a new requester
func NewRequesterWithClient ¶
NewRequesterWithClient creates a new requester with a custom HTTP client.
func (*Requester) Do ¶
Do sends a JSON request to server. The caller has to close the body of the response.
func (*Requester) DoWithRequest ¶
DoWithRequest sends a custom HTTP request to server.
type Response ¶
type Response struct { // Raw has a raw HTTP response. Raw *http.Response // contains filtered or unexported fields }
Response wraps a raw HTTP response. Response must only be manipulated from one goroutine (i.e. it isn't thread-safe).
func (*Response) Body ¶
Body returns the response body. Invoking this method will close Raw.Body. Don't call this method on a stream response (i.e. a response having unlimited length).
func (*Response) Error ¶
Error reads an error response from the server. It fails if the response isn't an error.
func (*Response) IsStream ¶
IsStream returns true when the response from the server is a stream which might have unbounded data.
func (*Response) ReadJSON ¶
ReadJSON reads the response body as a json and unmarshals it to the given data structure. This method closed the response body. This method can be called multiple times with different types of arguments. Don't call this method on a stream response (i.e. a response having unlimited length).
func (*Response) ReadStreamJSON ¶
ReadStreamJSON returns multiple parsed JSONs as interface{}. The caller must call Response.Close when it require no more JSONs.
func (*Response) StreamError ¶
StreamError returns an error which occurred in a goroutine spawned from ReadStreamJSON method. Don't call this method before the channel returned from ReadStreamJSON is closed.