api

package
v0.0.0-...-520922f Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2019 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent        = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0"
	HTTPBodyTypeJSON = "application/json"
)

Variables

This section is empty.

Functions

func Decorate

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

func LogMethodNotAllowedHandler

func LogMethodNotAllowedHandler() http.Handler

func LogNotFoundHandler

func LogNotFoundHandler() http.Handler

func LogPanicHandler

func LogPanicHandler() 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{})

Types

type APIHandler

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

func Log

func Log(f APIHandler) APIHandler

func V1

func V1(f APIHandler) APIHandler

type Decorator

type Decorator func(APIHandler) APIHandler

type Err

type Err struct {
	Code int
	Text string
}

func (Err) Error

func (e Err) Error() string

type HttpClient

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

func NewHttpClient

func NewHttpClient(connectTimeout time.Duration, requestTimeout time.Duration) *HttpClient

func (*HttpClient) HTTPGet

func (p *HttpClient) HTTPGet(url string) ([]byte, error)

func (*HttpClient) HTTPPostJSON

func (p *HttpClient) HTTPPostJSON(url string, body *bytes.Buffer) ([]byte, error)

Jump to

Keyboard shortcuts

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