Documentation ¶
Index ¶
- Constants
- func AddTracingWithGlobalTransport()
- func GetHTTPTransport(opts ...TransportOption) http.RoundTripper
- func GetInternalCertPair() (tls.Certificate, error)
- func GetInternalTLSConfig() (*tls.Config, error)
- func InternalEnableVerifyClientCert() bool
- func InternalTLSEnabled() bool
- func NewServerTLSConfig() *tls.Config
- func NewTransport(opts ...func(*http.Transport)) http.RoundTripper
- func WithIdleconnectionTimeout(idleConnectionTimeout time.Duration) func(*http.Transport)
- func WithInsecureSkipVerify(skipVerify bool) func(*http.Transport)
- func WithInternalTLSConfig() func(*http.Transport)
- func WithMaxIdleConns(maxIdleConns int) func(*http.Transport)
- type Client
- func (c *Client) Delete(url string) error
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(url string, v ...interface{}) error
- func (c *Client) GetAndIteratePagination(endpoint string, v interface{}) error
- func (c *Client) GetClient() *http.Client
- func (c *Client) Head(url string) error
- func (c *Client) Post(url string, v ...interface{}) error
- func (c *Client) Put(url string, v ...interface{}) error
- type Error
- type TransportConfig
- type TransportOption
Constants ¶
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 AddTracingWithGlobalTransport ¶
func AddTracingWithGlobalTransport()
func GetHTTPTransport ¶
func GetHTTPTransport(opts ...TransportOption) http.RoundTripper
GetHTTPTransport returns HttpTransport based on insecure configuration
func GetInternalCertPair ¶
func GetInternalCertPair() (tls.Certificate, error)
GetInternalCertPair used to get internal cert and key pair from environment
func GetInternalTLSConfig ¶
GetInternalTLSConfig return a tls.Config for internal https communicate
func InternalEnableVerifyClientCert ¶
func InternalEnableVerifyClientCert() bool
InternalEnableVerifyClientCert returns true if mTLS enabled
func InternalTLSEnabled ¶
func InternalTLSEnabled() bool
InternalTLSEnabled returns true if internal TLS enabled
func NewServerTLSConfig ¶
NewServerTLSConfig returns a modern tls config, refer to https://blog.cloudflare.com/exposing-go-on-the-internet/
func NewTransport ¶
func NewTransport(opts ...func(*http.Transport)) http.RoundTripper
NewTransport returns a new http.Transport with the specified options
func WithIdleconnectionTimeout ¶
WithIdleconnectionTimeout returns a TransportOption that configures the transport to use the specified idle connection timeout
func WithInsecureSkipVerify ¶
WithInsecureSkipVerify returns a TransportOption that configures the transport to skip verification of the server's certificate
func WithInternalTLSConfig ¶
WithInternalTLSConfig returns a TransportOption that configures the transport to use the internal TLS configuration
func WithMaxIdleConns ¶
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 ¶
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) GetAndIteratePagination ¶
GetAndIteratePagination iterates the pagination header and returns all resources The parameter "v" must be a pointer to a slice
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