Documentation
¶
Overview ¶
Package sourcehut provides access to the Sourcehut HTTP API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is like http.Client except that it knows how to authenticate to the Sourcehut API.
func NewBaseClient ¶
NewBaseClient returns a new Sourcehut API client configured to use the provided http.Client to perform HTTP requests.
To add authentication use NewClient or provide a base client that is authenticated with the Sourcehut API.
func (Client) Do ¶
Do sends an API request and returns the API response. The response is unmarshaled into v if successful, or returned as an error value if an API error has occured.
func (Client) List ¶
List returns an iterator that can transparently make API requests to a paginated endpoint. Each item will be decoded into the value returned from a call to d. If d is nil, a map[string]interface{} is created for each item.
No HTTP request will be issued until iteration is started by a call to Next.
type Error ¶
Error represents an individual error returned from a Sourcehut API call.
API docs: https://man.sr.ht/api-conventions.md#error-responses
type Iter ¶
type Iter struct {
// contains filtered or unexported fields
}
Iter provides a convenient API for iterating over the elements returned from paginated list API calls. Successive calls to the Next method step through each item in the list, fetching pages as needed.
func (*Iter) Current ¶
func (i *Iter) Current() interface{}
Current returns the most recent item visited by the iterator.
type Option ¶
type Option func(*Transport)
Option is used to configure a Sourcehut API client.
func RoundTripper ¶
func RoundTripper(rt http.RoundTripper) Option
RoundTripper returns an option that configures the client to use the provided http.RoundTripper for HTTP requests. If unspecified, http.DefaultTransport is used.
type Response ¶
type Response struct { *http.Response `json:"-"` Next string `json:"next"` Results json.RawMessage `json:"results"` ResultsPerPage int64 `json:"results_per_page"` Total int64 `json:"total"` }
Response is a Sourcehut API response. This wraps the standard http.Response and provides convenient access to pagination links.
API docs: https://man.sr.ht/api-conventions.md
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport is an http.RoundTripper wrapping a base RoundTripper and adding a Sourcehut API authorization header or user agent.
Transport is a low-level mechanism. Most code will use the NewClient method instead.
func NewTransport ¶
NewTransport returns an http.RoundTripper that is configured with the provided options.
func (*Transport) CancelRequest ¶
CancelRequest cancels an in-flight request by closing its connection.
If the underlying http.RoundTripper does not support cancelation, CancelRequest is a noop.
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
srht
Module
|
|
Package git provides easy API access to Sourcehut Git repositories.
|
Package git provides easy API access to Sourcehut Git repositories. |
internal
|
|
testlog
Package testlog is a log.Logger that proxies to the Log function on a testing.T. It is used to group log messages under the tests that generated them in test output and to only show those messages if the test that generated them failed.
|
Package testlog is a log.Logger that proxies to the Log function on a testing.T. It is used to group log messages under the tests that generated them in test output and to only show those messages if the test that generated them failed. |
Package lists provides easy API access to Sourcehut mailing lists.
|
Package lists provides easy API access to Sourcehut mailing lists. |
Package meta provides easy API access to Sourcehut account info.
|
Package meta provides easy API access to Sourcehut account info. |
Package paste provides easy API access to Sourcehut file pasting.
|
Package paste provides easy API access to Sourcehut file pasting. |