Documentation
¶
Overview ¶
Package request builds and executes HTTP requests against a resolved environment.
Index ¶
- Constants
- Variables
- func Data(value string, stdin io.Reader) ([]byte, error)
- func Fields(pairs []string) ([]byte, error)
- func NewClient(env *config.Environment, timeout time.Duration) (*http.Client, error)
- func NewStrictClient(env *config.Environment, timeout time.Duration) (*http.Client, error)
- func ParseHeaders(values []string) (http.Header, error)
- func ParseQuery(values []string) (url.Values, error)
- func ResolveURL(base *url.URL, rawPath string, query url.Values) (*url.URL, error)
- type Request
- type Response
Constants ¶
const MaxRedirects = 10
MaxRedirects matches the Go client's own default.
const StdinMarker = "@-"
StdinMarker is the --data value that means "read the body from stdin".
Variables ¶
var ErrRedirectRefused = errors.New("redirect refused")
ErrRedirectRefused marks a redirect blip declined to follow, so it surfaces as a safety refusal rather than as a network failure.
Functions ¶
func Data ¶
Data resolves a --data value: @file reads a file, @- reads stdin, anything else is the body itself.
func Fields ¶
Fields builds a flat JSON object from repeated key=value pairs. A key ending in a colon (key:=value) takes its value as raw JSON, which is the only way to send a number, a boolean or null without guessing at what a string was meant to be.
func NewStrictClient ¶
NewStrictClient builds a client for a host that is not the API's own, such as an OAuth2 token endpoint. It always verifies TLS: `insecure` is granted for a localhost development certificate, and must not follow a credential to an identity provider somewhere else.
func ParseHeaders ¶
ParseHeaders reads repeated --header values. Both "Name: value" and "Name=value" are accepted, because both are what people already have in their fingers.
func ParseQuery ¶
ParseQuery reads repeated --query values of the form name=value.
func ResolveURL ¶
ResolveURL applies a path and query to a base URL. A path prefix on the base URL is kept, so a base of https://host/api and a path of /orders give https://host/api/orders.