http

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InsecureTransport used to get the insecure http Transport
	InsecureTransport = iota
	// SecureTransport used to get the external secure http Transport
	SecureTransport
)

Variables

This section is empty.

Functions

func GetHTTPTransport

func GetHTTPTransport(opts ...TransportOption) http.RoundTripper

GetHTTPTransport returns HttpTransport based on insecure configuration

func NewTransport

func NewTransport(opts ...func(*http.Transport)) http.RoundTripper

NewTransport returns a new http.Transport with the specified options

func WithIdleconnectionTimeout

func WithIdleconnectionTimeout(idleConnectionTimeout time.Duration) func(*http.Transport)

WithIdleconnectionTimeout returns a TransportOption that configures the transport to use the specified idle connection timeout

func WithInsecureSkipVerify

func WithInsecureSkipVerify(skipVerify bool) func(*http.Transport)

WithInsecureSkipVerify returns a TransportOption that configures the transport to skip verification of the server's certificate

func WithMaxIdleConns

func WithMaxIdleConns(maxIdleConns int) func(*http.Transport)

WithMaxIdleConns returns a TransportOption that configures the transport to use the specified number of idle connections per host

Types

type Client

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

Client is a util for common HTTP operations, such Get, Head, Post, Put and Delete. Use Do instead if those methods can not meet your requirement

func NewClient

func NewClient(c *http.Client, modifiers ...modifier.Modifier) *Client

NewClient creates an instance of Client. Use net/http.Client as the default value if c is nil. Modifiers modify the request before sending it.

func (*Client) Delete

func (c *Client) Delete(url string) error

Delete ...

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do ...

func (*Client) Get

func (c *Client) Get(url string, v ...interface{}) error

Get ...

func (*Client) GetClient

func (c *Client) GetClient() *http.Client

GetClient returns the http.Client

func (*Client) Head

func (c *Client) Head(url string) error

Head ...

func (*Client) Post

func (c *Client) Post(url string, v ...interface{}) error

Post ...

func (*Client) Put

func (c *Client) Put(url string, v ...interface{}) error

Put ...

type TransportConfig

type TransportConfig struct {
	Insecure bool
}

TransportConfig is the configuration for http transport

type TransportOption

type TransportOption func(*TransportConfig)

TransportOption is the option for http transport

func WithInsecure

func WithInsecure(skipVerify bool) TransportOption

WithInsecure returns a TransportOption that configures the transport to skip verification of the server's certificate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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