client

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2024 License: MIT Imports: 10 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateURI

func GenerateURI(uri string, queryParams map[string]string) string

func GetResponseHeaders

func GetResponseHeaders(resp *fasthttp.Response) map[string]string

func SetHeaders

func SetHeaders(req *fasthttp.Request, headers map[string]string)

func SetHeadersInRequest

func SetHeadersInRequest(headers interface{}, req *fasthttp.Request) error

func SetQueryParamsInURI

func SetQueryParamsInURI(queryParams interface{}, uri string) (string, error)

SetQueryParamsInURI sets query parameters in the URI returns uri string without any error

func SetRequestBody

func SetRequestBody(body interface{}, req *fasthttp.Request) error

sets body if present and returns nil as error. Function will also return nil if body == nil

Types

type ClientInterface

type ClientInterface interface {
	Do(uri string, method string, queryParams any, headers any, body any) (*Response, error)
}

type ConcurrentResponse

type ConcurrentResponse struct {
	Response *Response
	Error    error
}

func MakeConcurrentRequests

func MakeConcurrentRequests(requests []*Request, client ClientInterface) []*ConcurrentResponse

func NewConcurrentResponse

func NewConcurrentResponse(response *Response, err error) *ConcurrentResponse

type FHClient

type FHClient struct {
	Client *fasthttp.Client
}

func NewFHClient

func NewFHClient(fasthttp *fasthttp.Client) *FHClient

func (*FHClient) Do

func (c *FHClient) Do(uri string, method string, queryParams any, headers any, reqBody any) (*Response, error)

type RateLimitedClient

type RateLimitedClient struct {
	Requests    int
	PerSeconds  int
	RateLimited *rate.Limiter
	FHClient    *FHClient
}

func NewRateLimitedClient

func NewRateLimitedClient(requests int, perSeconds int, fasthttp *fasthttp.Client) *RateLimitedClient

func (*RateLimitedClient) Do

func (rc *RateLimitedClient) Do(uri string, method string, queryParams any, headers any, reqBody any) (*Response, error)

type Request

type Request struct {
	Uri         string
	Method      string
	QueryParams any
	Headers     any
	Body        any
}

func NewRequest

func NewRequest(uri string, method string, queryParams any, headers any, body any) *Request

type Response

type Response struct {
	StatusCode  int
	Headers     map[string]string
	Body        []byte
	CurlCommand string
}

func Connect

func Connect(client ClientInterface, uri string, queryParams any, headers any) (*Response, error)

func Delete

func Delete(client ClientInterface, uri string, queryParams any, headers any, body any) (*Response, error)

func Get

func Get(client ClientInterface, uri string, queryParams any, headers any) (*Response, error)
func Head(client ClientInterface, uri string, queryParams any, headers any) (*Response, error)

func NewResponse

func NewResponse(statusCode int, headers map[string]string, body []byte, curlCmd string) *Response

func Options

func Options(client ClientInterface, uri string, queryParams any, headers any) (*Response, error)

func Patch

func Patch(client ClientInterface, uri string, queryParams any, headers any, body any) (*Response, error)

func Post

func Post(client ClientInterface, uri string, queryParams any, headers any, body any) (*Response, error)

func Put

func Put(client ClientInterface, uri string, queryParams any, headers any, body any) (*Response, error)

func Trace

func Trace(client ClientInterface, uri string, queryParams any, headers any) (*Response, error)

Jump to

Keyboard shortcuts

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