client

package
v0.0.0-...-1ee5a75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2015 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(x []string, r interface{}) error

func Encode

func Encode(r interface{}) ([]string, error)

Types

type Client

type Client struct {
	sync.RWMutex

	Address  string
	SockJS   *sockjs.Client
	Headers  map[string]string
	Incoming map[string]chan *Response
	Handlers []func(ev *Event)
	Timeout  time.Duration
	// contains filtered or unexported fields
}

func New

func New(address string, timeout time.Duration) (*Client, error)

func (*Client) CreateEmail

func (c *Client) CreateEmail(req *routes.EmailsCreateRequest) ([]string, error)

func (*Client) CreateToken

func (c *Client) CreateToken(req *routes.TokensCreateRequest) (*models.Token, error)

func (*Client) GetEmail

func (c *Client) GetEmail(id string) (*models.Email, error)

func (*Client) GetKey

func (c *Client) GetKey(id string) (*models.Key, error)

func (*Client) Loop

func (c *Client) Loop()

func (*Client) Receive

func (c *Client) Receive(id string) (*Response, error)

func (*Client) Request

func (c *Client) Request(method, path string, headers map[string]string, body interface{}) ([]string, string, error)

func (*Client) Subscribe

func (c *Client) Subscribe(token string, callback func(ev *Event)) error

type Event

type Event struct {
	Type string `json:"event"`
	ID   string `json:"id"`
	Name string `json:"name"`
}

type Request

type Request struct {
	Type    string            `json:"type,omitempty"`
	ID      string            `json:"id,omitempty"`
	Method  string            `json:"method,omitempty"`
	Path    string            `json:"path,omitempty"`
	Body    string            `json:"body,omitempty"`
	Token   string            `json:"token,omitempty"`
	Headers map[string]string `json:"headers,omitempty"`
}

type Response

type Response struct {
	Type    string              `json:"type,omitempty"`
	ID      string              `json:"id,omitempty"`
	Body    string              `json:"body,omitempty"`
	Name    string              `json:"name,omitempty"`
	Headers map[string][]string `json:"headers,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL