Documentation ¶
Overview ¶
Package api provides common utility functions for working with HTTP(S) APIs
Index ¶
- Variables
- func BuildBody(templateName string, data interface{}) (io.Reader, error)
- func BuildRequest(userAgent string, method string, reqPath string, reqBody io.Reader) (*http.Request, error)
- func Do(client *http.Client, req *http.Request, logger Logger) (res *http.Response, readBody string, err error)
- func DoBatch(client *http.Client, reqs []*http.Request, logger Logger) (resps []*http.Response, readBodies []string, errs []error)
- type Logger
- type LoggerFunc
- type RequestTemplate
Constants ¶
This section is empty.
Variables ¶
View Source
var RequestTemplates map[string]RequestTemplate
RequestTemplates provides a cache of RequestTemplates
Functions ¶
func BuildBody ¶
BuildBody returns the body of an API request built from the specified template and data
func BuildRequest ¶
func BuildRequest(userAgent string, method string, reqPath string, reqBody io.Reader) (*http.Request, error)
BuildRequest assembles an API request ready for transport
Types ¶
type LoggerFunc ¶
LoggerFunc provides a simple type for single function implementations of the Logger interface
func (LoggerFunc) Log ¶
func (f LoggerFunc) Log(m string) (err error)
Log defines the single method Logger interface
type RequestTemplate ¶
type RequestTemplate struct {
// contains filtered or unexported fields
}
RequestTemplate contains a *template.Template used to build API requests
Click to show internal directories.
Click to hide internal directories.