Documentation ¶
Index ¶
- Variables
- func ReadJSON(r io.ReadCloser, data interface{}) error
- func ReadSSE(r io.ReadCloser, ch chan *SSEEvent)
- func Req(opts *Options) (*http.Response, error)
- func WriteJSON(data interface{}) (io.Reader, error)
- type Authorizer
- type BasicAuthorizer
- type BearerAuthorizer
- type Error
- type Headers
- type Options
- type SSEEvent
Constants ¶
This section is empty.
Variables ¶
var ErrSSEParse = errors.New("could not parse event stream")
ErrSSEParse is used when an error occurred while parsing the SSE stream.
Functions ¶
func ReadJSON ¶
func ReadJSON(r io.ReadCloser, data interface{}) error
ReadJSON reads the content of the specified ReadCloser and closes it.
func ReadSSE ¶
func ReadSSE(r io.ReadCloser, ch chan *SSEEvent)
ReadSSE reads and parse a SSE source from a bufio.Reader into a channel of SSEEvent.
Types ¶
type Authorizer ¶
Authorizer is an interface to represent any element that can be used as a token bearer.
type BasicAuthorizer ¶
BasicAuthorizer implements the HTTP basic auth for authorization.
func (*BasicAuthorizer) AuthHeader ¶
func (b *BasicAuthorizer) AuthHeader() string
AuthHeader implemented the interface Authorizer.
func (*BasicAuthorizer) RealtimeToken ¶
func (b *BasicAuthorizer) RealtimeToken() string
RealtimeToken implemented the interface Authorizer.
type BearerAuthorizer ¶
type BearerAuthorizer struct {
Token string
}
BearerAuthorizer implements a placeholder authorizer if the token is already known.
func (*BearerAuthorizer) AuthHeader ¶
func (b *BearerAuthorizer) AuthHeader() string
AuthHeader implemented the interface Authorizer.
func (*BearerAuthorizer) RealtimeToken ¶
func (b *BearerAuthorizer) RealtimeToken() string
RealtimeToken implemented the interface Authorizer.
type Error ¶
type Error struct { Status string `json:"status"` Title string `json:"title"` Detail string `json:"detail"` }
Error is the typical JSON-API error returned by the API
type Options ¶
type Options struct { Addr string Domain string Scheme string Method string Path string Queries url.Values Headers Headers Body io.Reader Authorizer Authorizer ContentLength int64 NoResponse bool DisableSecure bool Client *http.Client UserAgent string ParseError func(res *http.Response, b []byte) error }
Options is a struct holding of the details of a request.
The NoResponse field can be used in case the call's response if not used. In such cases, the response body is automatically closed.