client

package
v0.0.0-...-120b264 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultHost    = "localhost:8080"
	DefaultTimeout = 1 * time.Minute
)

Default settings for the client.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represents an api client with an underlying http.Client instance.

func New

func New(opts ...Opt) Client

New creates a new client that connects to the given host.

func (Client) CharTrigram

func (c Client) CharTrigram(q string, regex bool) (api.CharTrigramResponse, error)

CharTrigram issues a new request for the given char-trigrams to the host and returns its response.

func (Client) Trigram

func (c Client) Trigram(f, s, t string) (api.TrigramResponse, error)

Trigram issues a new request for the given trigrams to the host and returns its response.

type Opt

type Opt func(*Client)

Opt is a functional option.

func WithHost

func WithHost(host string) Opt

WithHost defines a custom host configuration. c := client.New(client.WithHost("myhost"))

func WithLogger

func WithLogger(l logger.Logger) Opt

WithLogger sets the logger for the client to use. c := client.New(client.WithLogger(logger.New(...)))

func WithTimeout

func WithTimeout(to time.Duration) Opt

WithTimeout defines a custom timeout configuration c := client.New(client.WithTimeout(10 * time.Second))

Jump to

Keyboard shortcuts

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