httpagent

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2023 License: MIT Imports: 9 Imported by: 6

README

httpagent

一个简洁易用的 HTTP-User-Agent 客户端

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewModule

func NewModule()

NewModule ...

Types

type Client

type Client interface {
	Execute(req *Request) (*Response, error)
}

Client 是一个简易的 HTTP 客户端

type Clients

type Clients interface {
	GetClient() Client
	NewClient() Client
}

Clients 是一个简易的 HTTP 客户端服务

func Default

func Default() Clients

Default 获取默认的 Clients 对象

type Entity

type Entity struct {
	ContentLength int64
	ContentType   string
	Data          []byte
}

Entity ...

func (*Entity) OpenReader

func (inst *Entity) OpenReader() (io.ReadCloser, error)

OpenReader ...

func (*Entity) ReadBinary

func (inst *Entity) ReadBinary() ([]byte, error)

ReadBinary ...

func (*Entity) ReadJSON

func (inst *Entity) ReadJSON(obj any) error

ReadJSON ...

func (*Entity) ReadText

func (inst *Entity) ReadText() (string, error)

ReadText ...

type Headers

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

Headers ...

func (*Headers) Get

func (inst *Headers) Get(name string) string

Get ...

func (*Headers) Remove

func (inst *Headers) Remove(name string)

Remove ...

func (*Headers) Set

func (inst *Headers) Set(name, value string)

Set ...

func (*Headers) Table

func (inst *Headers) Table() map[string]string

Table ...

type Request

type Request struct {
	Context context.Context
	Method  string
	URL     string
	Headers Headers
	Body    io.ReadCloser
}

Request ...

func (*Request) SetEntity

func (inst *Request) SetEntity(entity *Entity)

SetEntity 设置请求的 body

type Response

type Response struct {
	Request *Request
	Status  int
	Message string
	Headers Headers
	Body    io.ReadCloser
}

Response ...

func (*Response) GetEntity

func (inst *Response) GetEntity() (*Entity, error)

GetEntity 以 Entity 的形式获取响应的 body

Directories

Path Synopsis
src
main/golang command

Jump to

Keyboard shortcuts

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