nexmo

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2019 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CallLimiter = NewLimiter(3)
	GetLimiter  = NewLimiter(15)
)
View Source
var ErrCorruptedContacts = errors.New("contacts file read contains corrupted data, thus the result could be partial")

Functions

func CallerFromRequest added in v0.0.4

func CallerFromRequest(r *http.Request) (string, error)

func LogEventHandler

func LogEventHandler(w http.ResponseWriter, r *http.Request)

func NewRouter

func NewRouter(c *Client, s Storage, origin string) *mux.Router

Types

type Client

type Client struct {
	AppID  string
	Number string
	Origin string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(pKeyR io.Reader, appID, number, origin string) (*Client, error)

func (*Client) Call

func (c *Client) Call(p ContactsProvider, recName string)

func (*Client) Do

func (c *Client) Do(method, url string, body io.Reader) (*http.Response, error)

func (*Client) Get

func (c *Client) Get(ctx context.Context, url string) (*http.Response, error)

func (*Client) Post

func (c *Client) Post(ctx context.Context, url string, body io.Reader) (*http.Response, error)

func (*Client) Token

func (c *Client) Token() (string, error)

type Contact

type Contact struct {
	Name   string `json:"-"`
	Type   string `json:"type"`
	Number string `json:"number"`
}

func DecodeContacts

func DecodeContacts(f func(io.Writer) error) ([]Contact, error)

func NewContact

func NewContact(num, name string) Contact

type ContactsProvider

type ContactsProvider interface {
	ReadBroadcastList(dest io.Writer) error
	ReadWhitelist(dest io.Writer) error
}

type Limiter

type Limiter struct {
	// contains filtered or unexported fields
}

func NewLimiter

func NewLimiter(r int) *Limiter

NewLimiter creates a new Limiter intance that allows `r` events per second to happen. It is a wrapper around rate.Limiter, configured with an burst of 1 and Limit of `r`.

func (*Limiter) Wait

func (l *Limiter) Wait(ctx context.Context) error

Wait blocks until the caller is allowed to perform a request acoording to the limiter's configuration.

type Storage

type Storage interface {
	ContactsProvider
	RecFileHandler() http.Handler
	WriteRec(src io.Reader, fileName string) (string, error)
}

Jump to

Keyboard shortcuts

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