requests

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateQueryParams

func GenerateQueryParams(data interface{}) string

GenerateQueryParams can be used as the container function for both GenerateQueryParamsForStrings and GenerateQueryParamsForAny.

func GenerateQueryParamsForAny

func GenerateQueryParamsForAny(queryParams map[string]any) string

GenerateQueryParamsForAny generates query params of map[string]any type.

func GenerateQueryParamsForStrings

func GenerateQueryParamsForStrings(queryParams map[string]string) string

GenerateQueryParamsForStrings generates query params of map[string]string type.

func GenerateUrl

func GenerateUrl(reqURL string, securityFlag bool, queryParams map[string]string) string

GenerateURL builds the URL for the request

Types

type BaseRequest

type BaseRequest struct {
	Method        string
	URL           string
	Headers       map[string]any
	Cookies       map[string]string
	Body          string
	BasicAuth     auth.BaseAuth
	MultipartBody io.Reader
	Writer        *multipart.Writer
}

BaseRequest is the base request object

func NewRequest

func NewRequest(method, url string) BaseRequest

NewBaseRequest creates a new BaseRequest object

func (*BaseRequest) AddQueryString

func (req *BaseRequest) AddQueryString(queryParams map[string]any)

AddQueryParams adds a query string to the request url.

func (*BaseRequest) Send

func (req *BaseRequest) Send(ss, sh, sb, redirect bool) (*rs.Response, error)

Send function sends the request to the server.

func (*BaseRequest) WithBody

func (req *BaseRequest) WithBody(body string, form *bool, multipart bool) *BaseRequest

WithBody adds body to the request based on the request body data type and form flags.

func (*BaseRequest) WithCookie

func (req *BaseRequest) WithCookie(key string, value string) *BaseRequest

WithCookies adds single cookie to the request

func (*BaseRequest) WithHeader

func (req *BaseRequest) WithHeader(key string, value string) *BaseRequest

WithHeaders adds single header to the request

func (*BaseRequest) WithHeaders

func (req *BaseRequest) WithHeaders(jsonData js.Json) (*BaseRequest, error)

WithHeaders converts json to map and adds it to the request headers.

func (*BaseRequest) WithHeadersMap

func (req *BaseRequest) WithHeadersMap(headersMap *(map[string]string)) *BaseRequest

WithHeadersMap adds the key-value of a map to the request headers.

type DeleteRequest

type DeleteRequest struct {
	BaseRequest
}

type GetRequest

type GetRequest struct {
	BaseRequest
}

type HeadRequest

type HeadRequest struct {
	BaseRequest
}

type OptionsRequest

type OptionsRequest struct {
	BaseRequest
}

type PatchRequest

type PatchRequest struct {
	BaseRequest
}

type PostRequest

type PostRequest struct {
	BaseRequest
}

type PutRequest

type PutRequest struct {
	BaseRequest
}

Jump to

Keyboard shortcuts

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