http_api

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2018 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompressHandler added in v0.3.6

func CompressHandler(h http.Handler) http.Handler

CompressHandler gzip compresses HTTP responses for clients that support it via the 'Accept-Encoding' header.

func Decorate added in v0.3.6

func Decorate(f APIHandler, ds ...Decorator) httprouter.Handle

func GetTopicChannelArgs

func GetTopicChannelArgs(rp getter) (string, string, error)

func LogMethodNotAllowedHandler added in v0.3.6

func LogMethodNotAllowedHandler(logf lg.AppLogFunc) http.Handler

func LogNotFoundHandler added in v0.3.6

func LogNotFoundHandler(logf lg.AppLogFunc) http.Handler

func LogPanicHandler added in v0.3.6

func LogPanicHandler(logf lg.AppLogFunc) func(w http.ResponseWriter, req *http.Request, p interface{})

func NewDeadlineTransport

func NewDeadlineTransport(connectTimeout time.Duration, requestTimeout time.Duration) *http.Transport

A custom http.Transport with support for deadline timeouts

func RespondV1

func RespondV1(w http.ResponseWriter, code int, data interface{})

func Serve

func Serve(listener net.Listener, handler http.Handler, proto string, logf lg.AppLogFunc)

Types

type APIHandler added in v0.3.6

type APIHandler func(http.ResponseWriter, *http.Request, httprouter.Params) (interface{}, error)

func PlainText added in v0.3.6

func PlainText(f APIHandler) APIHandler

func V1 added in v0.3.6

func V1(f APIHandler) APIHandler

type Client added in v0.3.6

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

func NewClient added in v0.3.6

func NewClient(tlsConfig *tls.Config, connectTimeout time.Duration, requestTimeout time.Duration) *Client

func (*Client) GETV1 added in v0.3.6

func (c *Client) GETV1(endpoint string, v interface{}) error

GETV1 is a helper function to perform a V1 HTTP request and parse our NSQ daemon's expected response format, with deadlines.

func (*Client) POSTV1 added in v0.3.6

func (c *Client) POSTV1(endpoint string) error

PostV1 is a helper function to perform a V1 HTTP request and parse our NSQ daemon's expected response format, with deadlines.

type Decorator added in v0.3.6

type Decorator func(APIHandler) APIHandler

func Log added in v0.3.6

func Log(logf lg.AppLogFunc) Decorator

type Err

type Err struct {
	Code int
	Text string
}

func (Err) Error

func (e Err) Error() string

type ReqParams

type ReqParams struct {
	url.Values
	Body []byte
}

func NewReqParams

func NewReqParams(req *http.Request) (*ReqParams, error)

func (*ReqParams) Get

func (r *ReqParams) Get(key string) (string, error)

func (*ReqParams) GetAll

func (r *ReqParams) GetAll(key string) ([]string, error)

Jump to

Keyboard shortcuts

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