man

package
v0.0.0-...-67aac8e Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeadJSON is the const content type of JSON.
	HeadJSON = "application/json; charset=utf-8"
)

Variables

This section is empty.

Functions

func DrainBody

func DrainBody(b io.ReadCloser) (r1 []byte, r2 io.ReadCloser, err error)

DrainBody reads all of b to memory and then returns two equivalent ReadClosers yielding the same bytes.

It returns an error if the initial slurp of all bytes fails. It does not attempt to make the returned ReadClosers have identical error-matching behavior.

func New

func New(man interface{}, optionFns ...OptionFn)

New makes a new Man for http requests.

func NewE

func NewE(man interface{}, optionFns ...OptionFn) error

New makes a new Man for http requests.

Types

type DownloadFile

type DownloadFile struct {
	Filename string
	Writer   io.Writer
}

DownloadFile represents the downloaded file.

type DumpRequestLogger

type DumpRequestLogger interface {
	// Dump logs the dmp
	Dump(dump []byte)
}

DumpRequestLogger is the interface for http dump.

type DumpResponseLogger

type DumpResponseLogger interface {
	// Dump logs the dmp
	Dump(dump []byte)
}

DumpResponseLogger is the interface for http dump.

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

HTTPClient defines the interface for HTTP client.

type Keepalive

type Keepalive string

Keepalive is the keep-alive flag (true(on,yes,1) /false(no, off,0), default true.

func (Keepalive) IsKeepAlive

func (k Keepalive) IsKeepAlive() bool

IsKeepAlive tells the keepalive option is enabled or not.

type Logger

type Logger interface {
	// LogError logs the error
	LogError(err error)
}

Logger is the interface for http logging.

type LoggerNoop

type LoggerNoop struct{}

LoggerNoop implements the interface for dao logging with NOOP.

func (*LoggerNoop) LogError

func (d *LoggerNoop) LogError(err error)

LogError logs the error

type Method

type Method string

Method is the HTTP Method for the http requests.

type Option

type Option struct {
	// URL ...
	URL string

	// Method ...
	Method string
	// Keepalive ...
	Keepalive string
	// Timeout ...
	Timeout string
	// TLSConfFiles like clientKeyFile,clientCertFile,serverRootCA(required=false)
	TLSConfFiles string
	TLSConfDir   string

	ErrSetter func(err error)
	Logger    Logger

	Client HTTPClient
	// contains filtered or unexported fields
}

Option is the options for Man.

type OptionFn

type OptionFn func(*Option)

OptionFn is the func prototype for Option.

func WithClient

func WithClient(c HTTPClient) OptionFn

WithClient specifies the http client for the man.

type StructField

type StructField struct {
	Parent      *StructValue
	Field       reflect.Value
	Index       int
	StructField reflect.StructField
	Type        reflect.Type
	Name        string
	Tag         reflect.StructTag
	Kind        reflect.Kind
	PkgPath     string
}

StructField represents the information of a struct's field

type StructValue

type StructValue struct {
	StructSelf reflect.Value
	NumField   int
	FieldTypes []reflect.StructField
}

StructValue represents the

func MakeStructValue

func MakeStructValue(structSelf reflect.Value) *StructValue

MakeStructValue makes a StructValue by a struct's value.

func (*StructValue) FieldByIndex

func (s *StructValue) FieldByIndex(index int) StructField

FieldByIndex return the StructField at index

type T

type T struct{}

T is the a special interface for additional tag for the man1.

type TLSConfDir

type TLSConfDir string

TLSConfDir specifies the TLSFiles configuration files directly for the client. like client.key,client.pem,root.pem

type TLSConfFiles

type TLSConfFiles string

TLSConfFiles specifies the TLS configuration files for the client. like client.key,client.pem,root.pem

type Timeout

type Timeout string

Timeout is the timeout setting for the http requests.

type URL

type URL string

URL is the URL address for the http requests.

func QueryURL

func QueryURL(baseURL string, kvs ...string) URL

QueryURL composes the GET url with query arguments

type UploadFile

type UploadFile struct {
	FilenameKey string
	Filename    string
	Reader      io.Reader
}

UploadFile represents the upload file to be uploaded.

func MakeFile

func MakeFile(filenameKey, filename string, reader io.Reader) UploadFile

MakeFile makes a file to upload.

Jump to

Keyboard shortcuts

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