http

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SkipGlobalValidateResponseCode = "ghem.download.skip.GlobalValidateResponseCode"
)

Variables

View Source
var (
	GlobalEvalResponsePlugins []EvalResponsePlugin

	ErrNoBody = errors.New("no body")
)
View Source
var (
	Client = http.DefaultClient
)
View Source
var (
	GlobalBeforeEvalResponsePlugins = []BeforeEvalResponsePlugin{
		GlobalValidateResponseCode(),
	}
)
View Source
var (
	GlobalBeforeRequestPlugins []BeforeRequestPlugin
)

Functions

func Execute

func Execute(url string, plugins ...Plugin) error

Types

type BeforeEvalResponseFunc

type BeforeEvalResponseFunc func(context.Context, *http.Response, *http.Request) (context.Context, *http.Response, error)

func (BeforeEvalResponseFunc) BeforeEvalResponse

func (instance BeforeEvalResponseFunc) BeforeEvalResponse(ctx context.Context, resp *http.Response, req *http.Request) (context.Context, *http.Response, error)

func (BeforeEvalResponseFunc) Self

func (instance BeforeEvalResponseFunc) Self() Plugin

type BeforeEvalResponsePlugin

type BeforeEvalResponsePlugin interface {
	Plugin
	BeforeEvalResponse(context.Context, *http.Response, *http.Request) (context.Context, *http.Response, error)
}

func GlobalValidateResponseCode

func GlobalValidateResponseCode() BeforeEvalResponsePlugin

type BeforeRequestFunc

type BeforeRequestFunc func(context.Context, *http.Request) (context.Context, *http.Request, error)

func (BeforeRequestFunc) BeforeRequest

func (instance BeforeRequestFunc) BeforeRequest(ctx context.Context, req *http.Request) (context.Context, *http.Request, error)

func (BeforeRequestFunc) Self

func (instance BeforeRequestFunc) Self() Plugin

type BeforeRequestPlugin

type BeforeRequestPlugin interface {
	Plugin
	BeforeRequest(context.Context, *http.Request) (context.Context, *http.Request, error)
}

func BasicAuth

func BasicAuth(user, password string) BeforeRequestPlugin

func BearerAuth

func BearerAuth(token string) BeforeRequestPlugin
func Header(name, value string) BeforeRequestPlugin

func Method

func Method(method string) BeforeRequestPlugin

type EvalResponseFunc

type EvalResponseFunc func(context.Context, *http.Response, *http.Request) error

func EvalBody

func EvalBody(onBody OnBody) EvalResponseFunc

func WriteTo

func WriteTo(writer io.Writer) EvalResponseFunc

func WriteToFile

func WriteToFile(filename string, perm os.FileMode) EvalResponseFunc

func WriteToTemporaryFile

func WriteToTemporaryFile(dir, pattern string, onTempFile OnTempFile) EvalResponseFunc

func (EvalResponseFunc) EvalResponse

func (instance EvalResponseFunc) EvalResponse(ctx context.Context, resp *http.Response, req *http.Request) error

func (EvalResponseFunc) Self

func (instance EvalResponseFunc) Self() Plugin

type EvalResponsePlugin

type EvalResponsePlugin interface {
	Plugin
	EvalResponse(context.Context, *http.Response, *http.Request) error
}

type OnBody

type OnBody func(io.Reader) error

type OnTempFile

type OnTempFile func(*os.File) error

type Plugin

type Plugin interface {
	Self() Plugin
}

Jump to

Keyboard shortcuts

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