httphelper

package
v0.0.0-...-e521c0d Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserIDNotFound = errors.New("userID not found in token claims")

Functions

func DecodeHTTPResponseBody

func DecodeHTTPResponseBody(res *http.Response) ([]byte, error)

DecodeHTTPResponseBody decodes HTTP response bytesBody based on Content-Encoding header.

func GetHTMLElemValue

func GetHTMLElemValue(body []byte, selector string) (string, error)

func GetSecCHUA

func GetSecCHUA(userAgent string) string

GetSecCHUA constructs the Sec-CH-UA header value based on the User-Agent.

func GetSecCHUAPlatform

func GetSecCHUAPlatform(userAgent string) string

GetSecCHUAPlatform extracts platform from user agent string.

func GetUserAgent

func GetUserAgent() string

func MergeCookies

func MergeCookies(httpRes *http.Response, cookies []*http.Cookie) []*http.Cookie

func NewRequest

func NewRequest(
	ctx context.Context,
	method string,
	url string,
	opts ...NewRequestOpt,
) (*http.Request, error)

func ParseJWTClaimsInt

func ParseJWTClaimsInt(tokenString string, fieldName string) (int, error)

Types

type NewRequestOpt

type NewRequestOpt func(*newRequestOpts)

func WithBytesBody

func WithBytesBody(body []byte) NewRequestOpt

func WithCookies

func WithCookies(cookies []*http.Cookie) NewRequestOpt

func WithHeaders

func WithHeaders(headers map[string]string) NewRequestOpt

func WithJSONBody

func WithJSONBody(body any) NewRequestOpt

Jump to

Keyboard shortcuts

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