http_api

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2015 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GETV1

func 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 GetTopicChannelArgs

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

func NegotiateV1

func NegotiateV1(method string, endpoint string, body io.Reader) (*simplejson.Json, error)

NegotiateV1 is a helper function to perform a v1 HTTP request and fallback to parsing the old backwards-compatible response format

func NegotiateVersionWrapper

func NegotiateVersionWrapper(w http.ResponseWriter, req *http.Request, f func() (interface{}, error))

func NewDeadlineTransport

func NewDeadlineTransport(timeout time.Duration) *http.Transport

A custom http.Transport with support for deadline timeouts

func RequirePOST

func RequirePOST(req *http.Request, f func() (interface{}, error)) func() (interface{}, error)

func Respond

func Respond(w http.ResponseWriter, statusCode int, statusTxt string, data interface{})

func RespondV1

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

func Serve

func Serve(listener net.Listener, handler http.Handler, l app.Logger, proto string)

func V1Wrapper

func V1Wrapper(w http.ResponseWriter, req *http.Request, f func() (interface{}, error))

Types

type Err

type Err struct {
	Code int
	Text string
}

func (Err) Error

func (e Err) Error() string

type PostParams

type PostParams struct {
	*http.Request
}

func (*PostParams) Get

func (p *PostParams) Get(key string) (string, error)

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