Documentation ¶
Index ¶
- type Connection
- func (c *Connection) GET()
- func (c *Connection) Get(completion func(Response, error))
- func (c *Connection) POST()
- func (c *Connection) Post(completion func(Response, error))
- func (c *Connection) PutHeader(key, value string)
- func (c *Connection) SetBasicAuth(username string, password string)
- func (c *Connection) SetContentType(contentType string)
- func (c *Connection) SetMethod(method HTTP_METHOD)
- func (c *Connection) SetNumberOfRetries(number int)
- func (c *Connection) SetTimeout(timeoutInSeconds time.Duration)
- func (c *Connection) UPLOAD()
- func (c *Connection) Upload(completion func(Response, error))
- type ConnectionBuilder
- type ConnectionState
- type FileWrapper
- type FileWrapperBuilder
- func (fwb *FileWrapperBuilder) Build() FileWrapper
- func (fwb *FileWrapperBuilder) SetContentType(contentType string) *FileWrapperBuilder
- func (fwb *FileWrapperBuilder) SetData(data []byte) *FileWrapperBuilder
- func (fwb *FileWrapperBuilder) SetName(name string) *FileWrapperBuilder
- func (fwb *FileWrapperBuilder) SetPath(path string) *FileWrapperBuilder
- type HTTP_METHOD
- type IdealResponse
- type OnClosed
- type OnError
- type OnProgress
- type OnReceived
- type OnStarted
- type OnStateChanged
- type Params
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { // Functions to handle connection states OnStarted OnStarted OnReceived OnReceived OnClosed OnClosed OnError OnError OnProgress OnProgress OnStateChanged OnStateChanged // contains filtered or unexported fields }
`Connection` a struct to help connect to the real world
func NewConnection ¶
func NewConnection(urlString string, params *Params) *Connection
NewConnection creates a new connection with the appropriate Dust auth headers.
func (*Connection) Get ¶
func (c *Connection) Get(completion func(Response, error))
Helper to send GET request with completion
func (*Connection) Post ¶
func (c *Connection) Post(completion func(Response, error))
Helper to send POST request with completion
func (*Connection) PutHeader ¶
func (c *Connection) PutHeader(key, value string)
Add header, like Authorization or custom
func (*Connection) SetBasicAuth ¶
func (c *Connection) SetBasicAuth(username string, password string)
Add basic authorization to the headers
func (*Connection) SetContentType ¶
func (c *Connection) SetContentType(contentType string)
func (*Connection) SetMethod ¶
func (c *Connection) SetMethod(method HTTP_METHOD)
Set method type. E.g.: GET, POST
func (*Connection) SetNumberOfRetries ¶
func (c *Connection) SetNumberOfRetries(number int)
Set number of retries for a HTTP request
func (*Connection) SetTimeout ¶
func (c *Connection) SetTimeout(timeoutInSeconds time.Duration)
Set timeout for the connection
func (*Connection) UPLOAD ¶
func (c *Connection) UPLOAD()
Helper to send UPLOAD (type of POST request) request This should be used while POST'ing MULTIPART-FORM
func (*Connection) Upload ¶
func (c *Connection) Upload(completion func(Response, error))
Helper to send UPLOAD (type of POST request) request with completion This should be used while POST'ing MULTIPART-FORM
type ConnectionBuilder ¶
type ConnectionBuilder struct {
// contains filtered or unexported fields
}
ConnectionBuilder is used to help build a `Connection`.
func (*ConnectionBuilder) Build ¶
func (cb *ConnectionBuilder) Build() Connection
Build a `Connection`
func (*ConnectionBuilder) SetMethod ¶
func (cb *ConnectionBuilder) SetMethod(method HTTP_METHOD) *ConnectionBuilder
Set HTTP Method type for a HTTP request
func (*ConnectionBuilder) SetParams ¶
func (cb *ConnectionBuilder) SetParams(params *Params) *ConnectionBuilder
Set `Params` for a HTTP request
func (*ConnectionBuilder) SetUrlString ¶
func (cb *ConnectionBuilder) SetUrlString(urlString string) *ConnectionBuilder
Set url string for a HTTP request
type ConnectionState ¶
type ConnectionState string
const ( CONNECTION_STATE_DISCONNECTED ConnectionState = "Disconnected" CONNECTION_STATE_CONNECTING ConnectionState = "Connecting" CONNECTION_STATE_CONNECTED ConnectionState = "Connected" )
type FileWrapper ¶
type FileWrapper struct {
// contains filtered or unexported fields
}
FileWrapper contains all necessary file data for upload.
func NewFileWrapper ¶
func NewFileWrapper() FileWrapper
type FileWrapperBuilder ¶
type FileWrapperBuilder struct {
// contains filtered or unexported fields
}
FileWrapperBuilder implements builder pattern to construct a FileWrapper
func NewFileWrapperBuilder ¶
func NewFileWrapperBuilder() *FileWrapperBuilder
func (*FileWrapperBuilder) Build ¶
func (fwb *FileWrapperBuilder) Build() FileWrapper
func (*FileWrapperBuilder) SetContentType ¶
func (fwb *FileWrapperBuilder) SetContentType(contentType string) *FileWrapperBuilder
func (*FileWrapperBuilder) SetData ¶
func (fwb *FileWrapperBuilder) SetData(data []byte) *FileWrapperBuilder
func (*FileWrapperBuilder) SetName ¶
func (fwb *FileWrapperBuilder) SetName(name string) *FileWrapperBuilder
func (*FileWrapperBuilder) SetPath ¶
func (fwb *FileWrapperBuilder) SetPath(path string) *FileWrapperBuilder
type HTTP_METHOD ¶
type HTTP_METHOD string
const ( HTTP_METHOD_GET HTTP_METHOD = "GET" HTTP_METHOD_POST HTTP_METHOD = "POST" HTTP_METHOD_UPLOAD HTTP_METHOD = "UPLOAD" )
type IdealResponse ¶
type IdealResponse interface {
// contains filtered or unexported methods
}
Future implementation for offline usage
type OnProgress ¶
type OnProgress func(progress int)
type OnReceived ¶
type OnReceived func(response Response)
type OnStateChanged ¶
type OnStateChanged func(state ConnectionState)
type Params ¶
type Params struct {
// contains filtered or unexported fields
}
`Params` a wrapper struct to hold URL/ File/ Post parameters for HTTP Connection
func QueryParams ¶
func (*Params) PutFile ¶
func (p *Params) PutFile(key string, value FileWrapper)
PutFile add a key/val pair to the RequestParams, where value is a FileWrapper.