httpclient

package
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: BSD-3-Clause Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const UserAgent = "gogutils_client/v0.2.1"

Variables

This section is empty.

Functions

This section is empty.

Types

type FormDataConfig

type FormDataConfig struct {
	Method  string
	URL     string
	Headers map[string]string
	Timeout time.Duration
	Fields  []FormDataField
}

type FormDataField

type FormDataField struct {
	Name  string
	Value string
	Text  bool
}

type HttpConfig

type HttpConfig struct {
	Method        string
	URL           string
	Headers       map[string]string
	Body          []byte
	Timeout       time.Duration
	LogResponse   bool
	Cache         bool
	RetrieveCache bool
	CacheTtl      int64
	UseProxy      bool
}

HTTPClientConfig contains the configuration for the HTTP client.

func ParseCurlCommand added in v1.0.9

func ParseCurlCommand(curlCommand string) (*HttpConfig, error)

ParseCurlCommand parses a curl command string and returns an HttpConfig.

type HttpResponse

type HttpResponse struct {
	Address     string
	Method      string
	ElapsedTime int64
	StatusCode  int
	Headers     map[string]string
	Body        []byte
	FromCache   bool
	CreatedUnix int64
	CacheTtl    int64
}

func Download

func Download(remoteURL string, headers map[string]string, filePath, uagent string) (HttpResponse, error)

Download downloads a file from a remote URL and saves it to a local file.

func MultipartData

func MultipartData(config HttpConfig, textFields map[string]string, fileFields map[string]string) (*HttpResponse, error)

func SendMultipartFormData

func SendMultipartFormData(config FormDataConfig) (*HttpResponse, error)

func SendRequest

func SendRequest(config HttpConfig) (*HttpResponse, error)

func (*HttpResponse) DeserializeCache

func (resp *HttpResponse) DeserializeCache(hash string) error

LoadFromFile deserializes the HttpResponse from a JSON file.

func (*HttpResponse) IsCacheEXpired

func (resp *HttpResponse) IsCacheEXpired() bool

func (*HttpResponse) SerializeCache

func (resp *HttpResponse) SerializeCache(hash string) error

SaveToFile serializes the HttpResponse to a JSON file.

type SoapConfig

type SoapConfig struct {
	URL     string
	Headers map[string]string
	Body    string
	Timeout time.Duration
	LogSoap bool
}

SoapConfig contains the configuration for the SOAP client.

type SoapResponse

type SoapResponse struct {
	ElapsedTime int64
	StatusCode  int
	Headers     map[string]string
	Body        string
}

SoapResponse represents the response from a SOAP call.

func SoapCall

func SoapCall(config SoapConfig) (*SoapResponse, error)

func (*SoapResponse) IsSuccess

func (resp *SoapResponse) IsSuccess() bool

Jump to

Keyboard shortcuts

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