rushgo

package
v0.0.0-...-68a1446 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractBetween

func ExtractBetween(body, left, right string) (string, error)

func ParseCookies

func ParseCookies(resp *http.Response) map[string]string

ParseCookies extracts and parses cookies from an http.Response and returns them as a map

func ParseJSON

func ParseJSON(data []byte) (map[string]interface{}, error)

ParseJSON parses a byte slice of JSON data into a map

func ParseXML

func ParseXML(data io.Reader) (map[string]string, error)

largely incomplete XML parser

func ResponseBodyContains

func ResponseBodyContains(responseBody []byte, searchStr string) bool

ResponseBodyContains checks if the response body contains a specific string

func Second

func Second(seconds int) time.Duration

Types

type Config

type Config struct {
	EnableHTTP2 bool
	EnableHTTP3 bool
	Timeout     time.Duration
}

Config struct for RushGo client settings

type RushGo

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

RushGo struct to encapsulate the http client and default headers

func New

func New(cfg *Config) *RushGo

New initializes a new RushGo instance with optional configuration

func (*RushGo) Delete

func (rg *RushGo) Delete(url string) (*http.Response, error)

Delete makes a DELETE request using the RushGo client

func (*RushGo) DownloadImage

func (rg *RushGo) DownloadImage(url string, savePath *string) (*http.Response, error)

DownloadImage downloads an image from the given URL and saves it to the specified path. If savePath is nil, the image is saved in the current working directory with its original filename. It returns the http.Response and an error, if any.

func (*RushGo) FollowRedirects

func (rg *RushGo) FollowRedirects() *RushGo

func (*RushGo) Get

func (rg *RushGo) Get(url string) (*http.Response, error)

Get makes a GET request using the RushGo client

func (*RushGo) Head

func (rg *RushGo) Head(url string) (*http.Response, error)

func (*RushGo) Options

func (rg *RushGo) Options(url string) (*http.Response, error)

func (*RushGo) Patch

func (rg *RushGo) Patch(url string, body []byte) (*http.Response, error)

Patch makes a PATCH request using the RushGo client

func (*RushGo) Post

func (rg *RushGo) Post(url string, body []byte) (*http.Response, error)

Post makes a POST request using the RushGo client

func (*RushGo) Put

func (rg *RushGo) Put(url string, body []byte) (*http.Response, error)

Put makes a PUT request using the RushGo client

func (*RushGo) SetCookies

func (rg *RushGo) SetCookies(cookies map[string]string) *RushGo

SetCookies sets cookies for the RushGo client without replacing the existing ones.

func (*RushGo) SetHeaders

func (rg *RushGo) SetHeaders(headers map[string]string) *RushGo

func (*RushGo) WebSocketConnect

func (rg *RushGo) WebSocketConnect(urlStr string) (*websocket.Conn, *http.Response, error)

func (*RushGo) WithBasicAuth

func (rg *RushGo) WithBasicAuth(username, password string) *RushGo

func (*RushGo) WithBearerToken

func (rg *RushGo) WithBearerToken(token string) *RushGo

func (*RushGo) WithCookies

func (rg *RushGo) WithCookies(cookies map[string]string) *RushGo

WithCookies sets cookies for the RushGo client's default headers.

func (*RushGo) WithHeaders

func (rg *RushGo) WithHeaders(headers map[string]string) *RushGo

WithHeaders sets default headers for the RushGo client

func (*RushGo) WithProxy

func (rg *RushGo) WithProxy(proxyURL string) *RushGo

func (*RushGo) WithTimeout

func (rg *RushGo) WithTimeout(timeout time.Duration) *RushGo

func (*RushGo) WithUserAgent

func (rg *RushGo) WithUserAgent(userAgent string) *RushGo

type UserAgent

type UserAgent string

func RandUserAgent

func RandUserAgent() UserAgent

func (UserAgent) String

func (ua UserAgent) String() string

Jump to

Keyboard shortcuts

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