httputil

package
v0.0.0-...-daa393d Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2020 License: CC-BY-SA-4.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gunzip

func Gunzip(v []byte) []byte

Extract the gzip bytes.

func Gzip

func Gzip(v []byte) []byte

Gzip the provided bytes.

Types

type Executor

type Executor interface {
	Post(url string, req, resp interface{}) error

	Put(url string, req, resp interface{}) error

	NewReq(method string, url string, req interface{}) (*http.Request, error)

	Execute(req *http.Request, resp interface{}) (*http.Response, error)
}

func NewExecutor

func NewExecutor(Logger Logger) Executor

type HttpResponseRecorder

type HttpResponseRecorder struct {
	http.ResponseWriter
	// contains filtered or unexported fields
}

HttpResponseRecorder is wrapper of http.ResponseWriter

func Recorder

Create a new http response recorder that can be used to copy the response, status code and headers.

func (*HttpResponseRecorder) Body

func (rec *HttpResponseRecorder) Body() []byte

A convenient method for extracting the recorded bytes. Note that if the content is encoded it will be decoded.

func (*HttpResponseRecorder) BodyString

func (rec *HttpResponseRecorder) BodyString() string

A convenient method for extracting the recorded bytes in a string format. Note that if the content is encoded it will be decoded.

func (*HttpResponseRecorder) Flush

func (rec *HttpResponseRecorder) Flush()

Write the copied body to the original http.ResponseWriter.

func (*HttpResponseRecorder) FlushWith

func (rec *HttpResponseRecorder) FlushWith(bytes []byte)

Write the provided bytes to the original http.ResponseWriter.

func (*HttpResponseRecorder) Header

func (rec *HttpResponseRecorder) Header() http.Header

func (*HttpResponseRecorder) Status

func (rec *HttpResponseRecorder) Status() int

Return the recorded status.

func (*HttpResponseRecorder) Write

func (rec *HttpResponseRecorder) Write(b []byte) (int, error)

func (*HttpResponseRecorder) WriteHeader

func (rec *HttpResponseRecorder) WriteHeader(s int)

type Logger

type Logger interface {
	Separator()

	TraceF(format string, vals ...interface{}) string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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