resty

package
v0.2.10-49 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: Apache-2.0 Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Name = "resty"
)

Variables

This section is empty.

Functions

func IsRedirect

func IsRedirect(statusCode int) bool

IsRedirect returns true if the status code indicates a redirect.

Types

type Client

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

Client is the IClient implementation

func New

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

func (*Client) Do

func (c *Client) Do(ctx context.Context, req *Request) (r result.Result[*fasthttp.Response])

type Config

type Config struct {
	BaseUrl              string            `yaml:"base_url"`
	ServiceName          string            `yaml:"service_name"`
	DefaultHeader        map[string]string `yaml:"default_header"`
	DefaultContentType   string            `yaml:"default_content_type"`
	DefaultRetryCount    uint32            `yaml:"default_retry_count"`
	DefaultRetryInterval time.Duration     `yaml:"default_retry_interval"`
	BasicToken           string            `yaml:"basic_token"`
	JwtToken             string            `yaml:"jwt_token"`

	EnableProxy               bool          `yaml:"enable_proxy"`
	EnableAuth                bool          `yaml:"enable_auth"`
	DialTimeout               time.Duration `yaml:"dial_timeout"`
	ReadTimeout               time.Duration `yaml:"read_timeout"`
	WriteTimeout              time.Duration `yaml:"write_timeout"`
	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"`
}

func DefaultCfg

func DefaultCfg() *Config

func (*Config) Build

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

type IClient

type IClient interface {
	Do(ctx context.Context, req *Request) result.Result[*fasthttp.Response]
}

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
}

type Request

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

func NewRequest

func NewRequest(cfg *RequestConfig) *Request

func (*Request) AddHeader

func (req *Request) AddHeader(key, value string) *Request

func (*Request) SetBackoff

func (req *Request) SetBackoff(backoff retry.Backoff) *Request

func (*Request) SetBody

func (req *Request) SetBody(body any) *Request

func (*Request) SetContentType

func (req *Request) SetContentType(contentType string) *Request

func (*Request) SetHeader

func (req *Request) SetHeader(key, value string) *Request

func (*Request) SetParam

func (req *Request) SetParam(key string, val string) *Request

func (*Request) SetParams

func (req *Request) SetParams(params map[string]string) *Request

func (*Request) SetQuery

func (req *Request) SetQuery(query map[string]string) *Request

type RequestConfig

type RequestConfig struct {
	Header      map[string]string
	Path        string
	Method      string
	ContentType string
	Backoff     retry.Backoff
	EnableAuth  bool
}

Jump to

Keyboard shortcuts

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