xhttp

package
v0.0.0-...-1147cba Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEHTML              = "text/html"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEPROTOBUF          = "application/x-protobuf"
	MIMEMSGPACK           = "application/x-msgpack"
	MIMEMSGPACK2          = "application/msgpack"
	MIMEYAML              = "application/x-yaml"
)

Content-Type MIME of the most common data formats.

View Source
const GroupPathHeader = "X-Group-Path"
View Source
const RequestIDHeader = "X-Request-ID"

Variables

This section is empty.

Functions

func NewOutgoingMetrics

func NewOutgoingMetrics(subsystem string, constLabels map[string]string) *outgoingMetrics

func NewRequestBuilder

func NewRequestBuilder() *builder

func NewRequestBuilderWithCtx

func NewRequestBuilderWithCtx(ctx context.Context) *builder

func NewTransport

func NewTransport(opts clientOptions) http.RoundTripper

Types

type Client

type Client interface {
	PostJSON(c context.Context, url string, data, target interface{}, reqOptions ...RequestOption) (int, error)
	PostForm(c context.Context, url string, data, target interface{}, reqOptions ...RequestOption) (int, error)
	Get(c context.Context, url string, target interface{}, reqOptions ...RequestOption) (int, error)
	GetWithQuery(c context.Context, url string, data, target interface{}, reqOptions ...RequestOption) (int, error)
	GetWithoutEncodedQuery(c context.Context,
		url string, data, target interface{}, reqOptions ...RequestOption) (int, error)
	Do(ctx context.Context, request *http.Request, target interface{}) (int, error)
}

func NewClient

func NewClient(opts ...Option) Client

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithBaseProm

func WithBaseProm(subSystem, recipient string) Option

func WithProm

func WithProm() Option

func WithPromConfig

func WithPromConfig(config PromConfig) Option

func WithProxyURL

func WithProxyURL(proxyURL string) Option

func WithSkipLog

func WithSkipLog(skipLog bool) Option

func WithSplitLogBody

func WithSplitLogBody(splitLen ...int) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

type PromConfig

type PromConfig struct {
	Enable     bool
	Subsystem  string
	ConstLabel map[string]string
	Register   prometheus.Registerer
}

func NewBasePromConfig

func NewBasePromConfig(subSystem, recipient string) PromConfig

func NewDefPromConfig

func NewDefPromConfig() PromConfig

type RequestOption

type RequestOption struct {
	Header    map[string]string
	GroupPath string
}

type Transport

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

func (*Transport) RoundTrip

func (t *Transport) RoundTrip(req *http.Request) (res *http.Response, err error)

Jump to

Keyboard shortcuts

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