rest

package module
v0.0.0-...-1c5cf23 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2019 License: MIT Imports: 15 Imported by: 0

README

rest

Documentation

Index

Constants

View Source
const (
	DefaultRequestTimeout = 15 * time.Second
)
View Source
const (
	DefaultServerShutdownTimeout = 15 * time.Second
)

Variables

This section is empty.

Functions

func NewProductionLogger

func NewProductionLogger() (*zap.Logger, error)

func WithShutdownTimeout

func WithShutdownTimeout(d time.Duration) func(*Server)

Types

type ReadCounter

type ReadCounter struct {
	io.Reader
	// contains filtered or unexported fields
}

func NewReadCounter

func NewReadCounter(r io.Reader) *ReadCounter

func (*ReadCounter) Read

func (rc *ReadCounter) Read(p []byte) (n int, err error)

func (*ReadCounter) Total

func (rc *ReadCounter) Total() int64

type Request

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

func R

func R() *Request

func (*Request) AddHeaders

func (r *Request) AddHeaders(headers map[string]string) *Request

func (*Request) AddQueryParams

func (r *Request) AddQueryParams(params map[string]string) *Request

func (*Request) Delete

func (r *Request) Delete() (*http.Response, error)

func (*Request) Do

func (r *Request) Do(method string) (*http.Response, error)

func (*Request) Get

func (r *Request) Get() (*http.Response, error)

func (*Request) Post

func (r *Request) Post() (*http.Response, error)

func (*Request) Put

func (r *Request) Put() (*http.Response, error)

func (*Request) SetBasicAuth

func (r *Request) SetBasicAuth(user, pass string) *Request

func (*Request) SetBody

func (r *Request) SetBody(rc io.ReadCloser) *Request

func (*Request) SetClient

func (r *Request) SetClient(client *http.Client) *Request

func (*Request) SetContext

func (r *Request) SetContext(ctx context.Context) *Request

func (*Request) SetJSON

func (r *Request) SetJSON(x interface{}) *Request

func (*Request) SetURL

func (r *Request) SetURL(url string) *Request

func (*Request) SetURLf

func (r *Request) SetURLf(format string, args ...interface{}) *Request

type Server

type Server struct {
	*http.Server
	// contains filtered or unexported fields
}

func NewServer

func NewServer(srv *http.Server, options ...func(*Server)) *Server

func (*Server) ListenAndServeContext

func (s *Server) ListenAndServeContext(ctx context.Context) error

func (*Server) ListenAndServeTLSContext

func (s *Server) ListenAndServeTLSContext(ctx context.Context, certFile, keyFile string) error

type WriteCounter

type WriteCounter struct {
	io.Writer
	// contains filtered or unexported fields
}

func NewWriteCounter

func NewWriteCounter(w io.Writer) *WriteCounter

func (*WriteCounter) Total

func (wc *WriteCounter) Total() int64

func (*WriteCounter) Write

func (wc *WriteCounter) Write(p []byte) (n int, err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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