curlhttp

package
v0.0.0-...-94edfc7 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module("curl", fx.Provide(FxNewCurlHttp))

Functions

func CurlHttpStatusCodeParser

func CurlHttpStatusCodeParser(source string) (string, error)

func ParseHTTPHeaders

func ParseHTTPHeaders(source string) map[string][]string

Types

type Config

type Config struct {
	Binary string
}

type CurlHttp

type CurlHttp struct {
	Config Config
	Log    *zap.Logger
}

func FxNewCurlHttp

func FxNewCurlHttp(p FxCurlHttpParams) *CurlHttp

func NewCurlHttp

func NewCurlHttp(p NewCurlHttpParams) *CurlHttp

func (*CurlHttp) Do

func (c *CurlHttp) Do(ctx context.Context, req Request) (Response, error)

type CurlRequest

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

func (*CurlRequest) AddHeader

func (c *CurlRequest) AddHeader(name string, value []string)

func (*CurlRequest) Body

func (c *CurlRequest) Body() io.Reader

func (*CurlRequest) Compressed

func (c *CurlRequest) Compressed() bool

func (*CurlRequest) Cookies

func (c *CurlRequest) Cookies() map[string]string

func (*CurlRequest) DisableCompression

func (c *CurlRequest) DisableCompression()

func (*CurlRequest) EnableCompression

func (c *CurlRequest) EnableCompression()

func (*CurlRequest) HTTP1

func (c *CurlRequest) HTTP1()

func (*CurlRequest) HTTP2

func (c *CurlRequest) HTTP2()

func (*CurlRequest) HTTP3

func (c *CurlRequest) HTTP3()

func (*CurlRequest) HTTPVersion

func (c *CurlRequest) HTTPVersion() string

func (*CurlRequest) Headers

func (c *CurlRequest) Headers() map[string][]string

func (*CurlRequest) Method

func (c *CurlRequest) Method() string

func (*CurlRequest) SetBody

func (c *CurlRequest) SetBody(reader io.Reader)

func (*CurlRequest) SetCookies

func (c *CurlRequest) SetCookies(cookies map[string]string)

func (*CurlRequest) SetMethod

func (c *CurlRequest) SetMethod(method string)

func (*CurlRequest) SetURL

func (c *CurlRequest) SetURL(url string)

func (*CurlRequest) SetUserAgent

func (c *CurlRequest) SetUserAgent(useragent string)

func (*CurlRequest) Url

func (c *CurlRequest) Url() string

func (*CurlRequest) UserAgent

func (c *CurlRequest) UserAgent() string

type CurlResponse

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

func (*CurlResponse) Body

func (c *CurlResponse) Body() io.Reader

func (*CurlResponse) Headers

func (c *CurlResponse) Headers() map[string][]string

func (*CurlResponse) HttpCode

func (c *CurlResponse) HttpCode() string

type FxCurlHttpParams

type FxCurlHttpParams struct {
	fx.In

	Config Config
	Log    *zap.Logger
}

type HTTPStatusCodeParser

type HTTPStatusCodeParser func(source string) (code string, err error)

type NewCurlHttpParams

type NewCurlHttpParams struct {
	Config Config
	Log    *zap.Logger
}

type Request

type Request interface {
	HTTPVersion() string
	Method() string
	Url() string
	Headers() map[string][]string
	Cookies() map[string]string
	UserAgent() string
	Compressed() bool
	Body() io.Reader
}

type Response

type Response interface {
	Body() io.Reader
	HttpCode() string
	Headers() map[string][]string
}

Jump to

Keyboard shortcuts

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