uhttp

package
v0.2.63 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2023 License: MIT Imports: 17 Imported by: 6

Documentation

Index

Constants

View Source
const (
	UrlTag    string = "url"
	HeaderTag string = "http"
)

Variables

This section is empty.

Functions

func HeaderString added in v0.2.18

func HeaderString(h http.Header) string

func HeaderTo added in v0.2.18

func HeaderTo(h http.Header, s any) (err error)

func IsEmpty added in v0.2.33

func IsEmpty(s string) bool

func Marshal added in v0.2.33

func Marshal(v any, omitempty bool) (s string, omit bool)

func OmitEmpty added in v0.2.33

func OmitEmpty(flags []string) bool

func Trace

func Trace(log *ulog.Log) func(Responce)

func TraceFormat

func TraceFormat(log *ulog.Log, format Format) func(Responce)

func UrlJoin added in v0.2.37

func UrlJoin(s ...any) string

Types

type Client

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

func NewClient

func NewClient() *Client

func (*Client) Clone

func (o *Client) Clone() *Client

func (*Client) Delete

func (o *Client) Delete(url string) *Performer

func (*Client) Get

func (o *Client) Get(url string) *Performer

func (*Client) Post

func (o *Client) Post(url string) *Performer

func (*Client) Put

func (o *Client) Put(url string) *Performer

func (*Client) Request

func (o *Client) Request(method string, url string) *Performer

func (*Client) Timeout

func (o *Client) Timeout() time.Duration

func (*Client) Url added in v0.2.25

func (o *Client) Url(url string) string

func (*Client) WithAppendPath added in v0.2.26

func (o *Client) WithAppendPath(path string) *Client

func (*Client) WithBase added in v0.2.25

func (o *Client) WithBase(base string) *Client

func (*Client) WithPath

func (o *Client) WithPath(path string) *Client

func (*Client) WithProxy

func (o *Client) WithProxy(proxy string) *Client

func (*Client) WithProxyUrl added in v0.2.21

func (o *Client) WithProxyUrl(url *url.URL) *Client

func (*Client) WithTimeout

func (o *Client) WithTimeout(timeout time.Duration) *Client

func (*Client) WithTrace

func (o *Client) WithTrace(trace func(Responce)) *Client

func (*Client) WithTraceFormat added in v0.2.19

func (o *Client) WithTraceFormat(log *ulog.Log, f Format) *Client

type Format

type Format struct {
	RequestParams  bool
	RequestHeader  bool
	ResponceHeader bool
	RequestBody    bool
	ResponceBody   bool
}

type Performer

type Performer struct {
	Request Request
	// contains filtered or unexported fields
}

func (*Performer) Auth

func (o *Performer) Auth(v string) *Performer

func (*Performer) AuthBearer

func (o *Performer) AuthBearer(token string) *Performer

func (*Performer) Body

func (o *Performer) Body(body []byte) *Performer

func (*Performer) ContentType

func (o *Performer) ContentType(v string) *Performer

func (*Performer) ContentTypeJson

func (o *Performer) ContentTypeJson() *Performer

func (*Performer) Do

func (o *Performer) Do() (r Responce)

func (*Performer) Header

func (o *Performer) Header(name string, value any) *Performer

func (*Performer) Headers

func (o *Performer) Headers(s any) *Performer

func (*Performer) Json

func (o *Performer) Json(v any) *Performer

func (*Performer) Param

func (o *Performer) Param(name string, value any) *Performer

func (*Performer) Params

func (o *Performer) Params(s any) *Performer

func (*Performer) Trace

func (o *Performer) Trace(trace func(Responce)) *Performer

type Request

type Request struct {
	Method string
	Url    string
	Params url.Values
	Header http.Header
	Body   []byte
}

func (*Request) BodyString

func (o *Request) BodyString() string

func (*Request) HeaderString

func (o *Request) HeaderString() string

func (*Request) ParamsString

func (o *Request) ParamsString() string

func (*Request) Path

func (o *Request) Path(path string)

func (*Request) RefineUrl added in v0.2.17

func (o *Request) RefineUrl()

func (*Request) Uri

func (o *Request) Uri() string

type Responce

type Responce struct {
	Request    Request
	Time       time.Duration
	Status     string
	StatusCode int
	Header     http.Header
	Body       []byte
	Error      error
}

func (*Responce) BodyExists added in v0.2.24

func (o *Responce) BodyExists() bool

func (*Responce) Format

func (o *Responce) Format(f Format) string

func (*Responce) HeaderExists added in v0.2.18

func (o *Responce) HeaderExists(key string) bool

func (*Responce) HeaderFloat64 added in v0.2.18

func (o *Responce) HeaderFloat64(key string) (float64, error)

func (*Responce) HeaderInt64 added in v0.2.18

func (o *Responce) HeaderInt64(key string) (int64, error)

func (*Responce) HeaderString added in v0.2.18

func (o *Responce) HeaderString() string

func (*Responce) HeaderTo added in v0.2.18

func (o *Responce) HeaderTo(v any) error

func (*Responce) HeaderValue added in v0.2.18

func (o *Responce) HeaderValue(key string) string

func (*Responce) Json

func (o *Responce) Json(v any) error

func (*Responce) Ok added in v0.2.17

func (o *Responce) Ok() bool

func (*Responce) RefineError

func (o *Responce) RefineError(text string, err error)

func (*Responce) Text added in v0.2.60

func (o *Responce) Text() string

func (*Responce) Title added in v0.2.17

func (o *Responce) Title() string

type Tracer

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

func NewTracer

func NewTracer(log *ulog.Log) *Tracer

func (*Tracer) Trace

func (o *Tracer) Trace(r Responce)

func (*Tracer) WithFormat added in v0.2.17

func (o *Tracer) WithFormat(f Format) *Tracer

Jump to

Keyboard shortcuts

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