http

package
v0.0.0-...-b89fbfb Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package http [allows sending customized http traffic]

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRequest

func InitRequest(c RequestConfig, req *fasthttp.Request) int64

InitRequest is used to populate data from request config to fasthttp.Request

Types

type Client

type Client interface {
	Do(req *fasthttp.Request, resp *fasthttp.Response) error
}

func NewClient

func NewClient(ctx context.Context, clientConfig ClientConfig, logger *zap.Logger) Client

NewClient creates a fasthttp client based on the config.

type ClientConfig

type ClientConfig struct {
	StaticHost      *StaticHostConfig `mapstructure:"static_host"`
	TLSClientConfig *tls.Config       `mapstructure:"tls_config,omitempty"`
	Timeout         *time.Duration    `mapstructure:"timeout"`
	ReadTimeout     *time.Duration    `mapstructure:"read_timeout"`
	WriteTimeout    *time.Duration    `mapstructure:"write_timeout"`
	IdleTimeout     *time.Duration    `mapstructure:"idle_timeout"`
	MaxIdleConns    *int              `mapstructure:"max_idle_connections"`
	ProxyURLs       string            `mapstructure:"proxy_urls"`
}

ClientConfig is a http client configuration structure

type RequestConfig

type RequestConfig struct {
	Path    string
	Method  string
	Body    string
	Headers map[string]string
	Cookies map[string]string
}

RequestConfig is a struct representing the config of a single request

type StaticHostConfig

type StaticHostConfig struct {
	Addr  string `mapstructure:"addr"`
	IsTLS bool   `mapstructure:"is_tls"`
}

Jump to

Keyboard shortcuts

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