httpaddon

package
v0.0.0-...-7b70c5d Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const Permission = "http"
View Source
const StatusExecuting = int(1)
View Source
const StatusFail = int(3)
View Source
const StatusReady = int(0)
View Source
const StatusSuccess = int(2)

Variables

View Source
var ErrRequestExecuted = errors.New("httpplugin: request executed")
View Source
var ErrRequestNotExecuted = errors.New("httpplugin: request not executed")

Functions

func DefaultIDGererator

func DefaultIDGererator() string

Types

type Addon

type Addon struct {
	IDGenerator func() string
	Client      *http.Client
	Permission  string
	Plugin      herbplugin.Plugin
}

func Create

func Create(p herbplugin.Plugin) *Addon

func (*Addon) Create

func (a *Addon) Create(method string, url string) *Request

type Preset

type Preset struct {
	Body   []byte
	Method string
	Header http.Header
	URL    string
	Proxy  string
}

func NewPreset

func NewPreset() *Preset

type Request

type Request struct {
	ID       string
	Preset   *Preset
	Status   int
	Response *Response
	// contains filtered or unexported fields
}

func (*Request) AddHeader

func (r *Request) AddHeader(name string, value string)

func (*Request) AsyncExecute

func (r *Request) AsyncExecute(callback func(error))

func (*Request) DelHeader

func (r *Request) DelHeader(name string)

func (*Request) ExecuteStauts

func (r *Request) ExecuteStauts() int

func (*Request) FinishedAt

func (r *Request) FinishedAt() int64

func (*Request) GetBody

func (r *Request) GetBody() []byte

func (*Request) GetHeader

func (r *Request) GetHeader(name string) string

func (*Request) GetID

func (r *Request) GetID() string

func (*Request) GetMethod

func (r *Request) GetMethod() string

func (*Request) GetProxy

func (r *Request) GetProxy() string

func (*Request) GetURL

func (r *Request) GetURL() string

func (*Request) HeaderFields

func (r *Request) HeaderFields() []string

func (*Request) HeaderValues

func (r *Request) HeaderValues(name string) []string

func (*Request) MustExecute

func (r *Request) MustExecute()

func (*Request) ResetHeader

func (r *Request) ResetHeader()

func (*Request) ResponseBody

func (r *Request) ResponseBody() []byte

func (*Request) ResponseHeader

func (r *Request) ResponseHeader(name string) string

func (*Request) ResponseHeaderFields

func (r *Request) ResponseHeaderFields() []string

func (*Request) ResponseHeaderValues

func (r *Request) ResponseHeaderValues(name string) []string

func (*Request) ResponseStatusCode

func (r *Request) ResponseStatusCode() int

func (*Request) SetBody

func (r *Request) SetBody(body []byte)

func (*Request) SetHeader

func (r *Request) SetHeader(name string, value string)

func (*Request) SetMethod

func (r *Request) SetMethod(method string)

func (*Request) SetProxy

func (r *Request) SetProxy(p string)

func (*Request) SetURL

func (r *Request) SetURL(url string)

type Response

type Response struct {
	FinishedAt int64
	StatusCode int
	Header     http.Header
	Body       []byte
}

func ConvertResponse

func ConvertResponse(resp *http.Response) (*Response, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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