Documentation ¶
Index ¶
Constants ¶
View Source
const ( DEFAULT_BRIDGE_ENDPOINT = "http://127.0.0.1:8989/" DEFAULT_BINDING_PORT = "8787" DEFAULT_BINDING_INTERFACE = "0.0.0.0" DEFAULT_BINDING = DEFAULT_BINDING_INTERFACE + ":" + DEFAULT_BINDING_PORT PRE_EVENT = "PRE" POST_EVENT = "POST" API_VERSION = "/v1" API_PING = API_VERSION + "/ping" API_SUBSCRIPTION = API_VERSION + "/subscriptions" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { // close the resource and unregister if required Close() error // register a hook in the API Subscribe(*Subscription, RequestsChannel) (string, error) // unsubscribe from the provider Unsubscribe(string) error // list the current subscriptions Subscriptions() ([]*Subscription, error) }
The client interface
type ClientImpl ¶
type ClientImpl struct {
// contains filtered or unexported fields
}
the implementation of the client
func (*ClientImpl) Close ¶
func (r *ClientImpl) Close() error
Request to close off any resources, disconnect our self as an endpoint (if required) and close the client
func (*ClientImpl) Subscribe ¶
func (r *ClientImpl) Subscribe(subscription *Subscription, channel RequestsChannel) (string, error)
Perform a registration request to the bridge
register: the registration structure containing the hooks channel: the channel you want to receive the api requests on
func (*ClientImpl) Subscriptions ¶
func (r *ClientImpl) Subscriptions() ([]*Subscription, error)
Retrieve a list of subscriptions from the bridge
func (*ClientImpl) Unsubscribe ¶
func (r *ClientImpl) Unsubscribe(id string) error
Unregister from the bridge.io service
id: the registration id which was given when you registered
type Config ¶
type Config struct { // the rest endpoint for the bridge io server - e.g http://127.0.0.1:8989 Bridge string `json:"bridge"` // the binding for the client i.e. where the endpoint will run Binding string `json:"bind"` // the token used to connect to bridge Token string `json:"token"` // the max time to wait for a request to fulfil MaxTime time.Duration }
the configuration of the client
func DefaultConfig ¶
func DefaultConfig() *Config
type Event ¶
type Event struct { // an id for the origin - normally the hostname ID string `json:"id"` // a timestamp for the request Stamp time.Time `json:"timestamp"` // the hook type HookType string `json:"type"` // the uri for the request URI string `json:"uri"` // the query string Query string `json:"query"` // the payload itself Request string `json:"request"` // contains filtered or unexported fields }
A structure to define and incoming request
type Hook ¶
type Hook struct { // should this hook be enforcing, i.e. if were not able to contact you, kill the request Enforcing bool `json:"enforcing"` // when the hook should be fired, i.e. pre, post or both HookType string `json:"type"` // the entry point for the request, a regex applied to URI URI string `json:"uri"` }
A Hook definition / request for access to the API
type MessageResponse ¶
type MessageResponse struct {
Message string `json:"message"`
}
type Subscription ¶
type Subscription struct { // an application ID ID string `json:"id"` // the endpoint to send these requests Subscriber string `json:"subscriber"` // an array of hook requests Requests []*Hook `json:"hooks"` }
A registration request structure: used buy the client register for hook events into the API
func (*Subscription) AddHook ¶
func (r *Subscription) AddHook(h *Hook)
func (*Subscription) PostHook ¶
func (r *Subscription) PostHook(uri string) *Subscription
func (*Subscription) PreHook ¶
func (r *Subscription) PreHook(uri string) *Subscription
func (Subscription) Valid ¶
func (r Subscription) Valid() error
type SubscriptionResponse ¶
type SubscriptionResponse struct {
ID string `json:"id"`
}
type SubscriptionsResponse ¶
type SubscriptionsResponse struct {
Subscriptions []*Subscription `json:"subscriptions"`
}
Click to show internal directories.
Click to hide internal directories.