resty

package
v0.2.10-38 Latest Latest
Warning

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

Go to latest
Published: Jun 25, 2023 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultTimeout = 10 * time.Second
)
View Source
const Name = "resty"

Variables

This section is empty.

Functions

func NewRequest

func NewRequest() *fasthttp.Request

func StatusCodeIsRedirect

func StatusCodeIsRedirect(statusCode int) bool

StatusCodeIsRedirect returns true if the status code indicates a redirect.

Types

type Client

type Client interface {
	Do(ctx context.Context, req *fasthttp.Request) result.Result[*fasthttp.Response]
	Head(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	Get(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	Delete(ctx context.Context, url string, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	Post(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	PostForm(ctx context.Context, url string, val url.Values, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	Put(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
	Patch(ctx context.Context, url string, data interface{}, opts ...func(req *fasthttp.Request)) result.Result[*fasthttp.Response]
}

Client http client interface

func New

func New(cfg *Config, p Params, mm ...lava.Middleware) Client

type Config

type Config struct {
	BaseUrl string `yaml:"base_url"`

	Timeout                   time.Duration     `yaml:"timeout"`
	ReadTimeout               time.Duration     `yaml:"read_timeout"`
	WriteTimeout              time.Duration     `yaml:"write_timeout"`
	RetryCount                uint32            `yaml:"retry_count"`
	Proxy                     bool              `yaml:"proxy"`
	Socks5                    string            `yaml:"socks5"`
	Insecure                  bool              `yaml:"insecure"`
	Header                    map[string]string `yaml:"header"`
	TargetService             string            `yaml:"target_service"`
	Token                     string            `yaml:"token"`
	JwtToken                  string            `yaml:"jwt_token"`
	UserAgent                 string            `yaml:"user_agent"`
	ContentType               string            `yaml:"content_type"`
	Accept                    string            `yaml:"accept"`
	Debug                     bool              `yaml:"debug"`
	Authentication            bool              `yaml:"authentication"`
	GzipRequest               bool              `yaml:"gzip_request"`
	MaxConnsPerHost           int               `yaml:"max_conns_per_host"`
	MaxIdleConnDuration       time.Duration     `yaml:"max_idle_conn_duration"`
	MaxIdemponentCallAttempts int               `yaml:"max_idemponent_call_attempts"`
	ReadBufferSize            int               `yaml:"read_buffer_size"`
	WriteBufferSize           int               `yaml:"write_buffer_size"`
	MaxResponseBodySize       int               `yaml:"max_response_body_size"`
	// contains filtered or unexported fields
}

func DefaultCfg

func DefaultCfg() *Config

func (*Config) Build

func (t *Config) Build() *fasthttp.Client

type Jar

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

func NewJar

func NewJar(log log.Logger) *Jar

func (*Jar) DecodeGOB

func (j *Jar) DecodeGOB(data []byte) error

func (*Jar) EncodeGOB

func (j *Jar) EncodeGOB() ([]byte, error)

func (*Jar) MarshalJSON

func (j *Jar) MarshalJSON() ([]byte, error)

func (*Jar) Middleware

func (j *Jar) Middleware(next lava.HandlerFunc) lava.HandlerFunc

func (*Jar) Peek

func (j *Jar) Peek(key string) *fasthttp.Cookie

func (*Jar) PeekValue

func (j *Jar) PeekValue(key string) []byte

func (*Jar) ReleaseCookie

func (j *Jar) ReleaseCookie(key string)

func (*Jar) String

func (j *Jar) String() string

func (*Jar) UnmarshalJSON

func (j *Jar) UnmarshalJSON(data []byte) error

type Params

type Params struct {
	Log                 log.Logger
	MetricMiddleware    *middleware_metric.MetricMiddleware
	AccessLogMiddleware *middleware_accesslog.LogMiddleware
}

Jump to

Keyboard shortcuts

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