httputil

package
v0.0.0-...-0bcc1f7 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAmbiguousValues     = errors.New("differing values found")
	ErrValueUnexpectedType = errors.New("value is an unexpected type")
)

Functions

This section is empty.

Types

type IPInfo

type IPInfo struct {
	City    string `json:"city"`
	Region  string `json:"region"`
	Country string `json:"country"`
	Org     string `json:"org"`
}

func (*IPInfo) GeoString

func (i *IPInfo) GeoString() string

type IPInfoClient

type IPInfoClient struct {
	BaseURL    string
	HttpClient http.Client
}

func (*IPInfoClient) GetIPInfo

func (c *IPInfoClient) GetIPInfo(ip string) (*IPInfo, error)

type JSONObject

type JSONObject map[string]interface{}

type RequestValues

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

func ParseRequest

func ParseRequest(req *http.Request) *RequestValues

returns a *RequestValues which lazily parses body and url values

func (*RequestValues) Body

func (p *RequestValues) Body() ([]byte, error)

func (*RequestValues) BodyText

func (p *RequestValues) BodyText() (string, error)

func (*RequestValues) ContentType

func (p *RequestValues) ContentType() string

func (*RequestValues) Form

func (p *RequestValues) Form() (url.Values, error)

func (*RequestValues) GetString

func (p *RequestValues) GetString(key string) (string, error)

returns the request value associated with key. if key is not found, returns empty string and nil error. if differing values are found, returns the first value and ErrAmbiguousValues. if an associated value is not a string, returns the first string, if any, and ErrValueUnexpectedType. may also return errors related to parsing the request.

func (*RequestValues) JSONObject

func (p *RequestValues) JSONObject() (JSONObject, error)

func (*RequestValues) Query

func (p *RequestValues) Query() url.Values

func (*RequestValues) Values

func (p *RequestValues) Values(key string) (vals []interface{}, err error)

returns all request values associated with key. parses values from request body and url based on method and content-type.

type TurnstileClient

type TurnstileClient struct {
	Secret     string
	HttpClient http.Client
}

func (*TurnstileClient) Verify

func (c *TurnstileClient) Verify(token string) (bool, error)

Jump to

Keyboard shortcuts

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