dreq

package
v0.0.0-...-5f7c8af Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Buf = &naked.Buf
View Source
var Log = &naked.Log

Functions

func Reqst

func Reqst(method, url string, plugFn ...PlugFn) (statusCode int, err error)

Types

type Dreq

type Dreq struct {
	Ctx       context.Context
	Cli       http.Client
	Req       *http.Request
	Res       *http.Response
	Buf       bytes.Buffer
	Log       bytes.Buffer
	Mux       sync.Mutex
	NoOutput  bool
	PlugFns   []PlugFn
	PlugFnErr []error
}

func New

func New(optionalFn ...func(d *Dreq)) *Dreq

New will create Dreq object and takes PlugFns. However, before each request, Buf, Req, Log, FnsPre/Post will be reset.

func (*Dreq) AddPlugFnErr

func (r *Dreq) AddPlugFnErr(err error)

func (*Dreq) Logf

func (r *Dreq) Logf(format string, a ...interface{})

func (*Dreq) Reqst

func (r *Dreq) Reqst(method, url string, plugFn ...PlugFn) (statusCode int, err error)

func (*Dreq) ResetPlugFn

func (r *Dreq) ResetPlugFn()

func (*Dreq) ResetPlugFnErrs

func (r *Dreq) ResetPlugFnErrs()

type PlugFn

type PlugFn struct {
	Name   string
	FnPre  func(d *Dreq)
	FnPost func(d *Dreq)
}

Optional custom function 1. FnPre: Before-Request-Send 2. FnPost: After-Request-Sent

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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