An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 9.0% on proxy.golang.org

proxy.golang.org : github.com/contextgg/requester

Package requester builds and executes HTTP requests. It's a thin wrapper around the http package with conveniences for configuring requests and processing responses. The central, package-level functions are: Context-aware variants are also available. requester.Requester{} has the same methods. A Requester instance can be used to repeat a request, as a template for similar requests across a REST API surface, or embedded in another type, as the core of a language binding to a REST API. The exported attributes of requester.Requester{} control how it constructs requests, what client it uses to execute them, and how the responses are handled. Most methods and functions in the package accept Options, which are functions that configure the attributes of Requesters. The package provides many options for configuring most attributes Requester. Receive() builds a request, executes it, and reads the response body. If a target value is provided, Receive will attempt to unmarshal the body into the target value. The body of the response, if present, is always returned as a []byte, even when unmarshaling or returning an error. By default, Receive uses the response's Content-Type header to determine how to unmarshal the response body into a struct. This can be customized by setting Requester.Unmarshaler: Requester.QueryParams will be merged into any query parameters encoded into the URL. For example: The QueryParams() option can take a map[string]string, a map[string]interface{}, a url.Values, or a struct. Structs are marshaled into url.Values using "github.com/google/go-querystring": If Requester.Body is set to a string, []byte, or io.Reader, the value will be used directly as the request body: If Body is any other value, it will be marshaled into the body, using the Requester.Marshaler: Note the default Marshaler is JSON, and sets the request's Content-Type header. The HTTP client used to execute requests can also be customized with Options: "github.com/gemalto/requester/httpclient" is a standalone package for constructing and configuring http.Clients. The requester.Client(...httpclient.Option) option constructs a new HTTP client and installs it into Requester.Doer. Requester uses a Doer to execute requests, which is an interface. By default, http.DefaultClient is used, but this can be replaced by a customized client, or a mock Doer: Requester itself is a Doer, so it can be nested in another Requester or composed with other packages that support Doers. You can also install middleware into Requester, which can intercept the request and response:

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/contextgg/requester
License: MIT
Latest release: about 3 years ago
First release: over 7 years ago
Namespace: github.com/contextgg
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 18 days ago

    Loading...
    Readme
    Loading...