Documentation
¶
Index ¶
- func Delete(rawurl string) ([]byte, error)
- func Fetch(fc FetchConfig) ([]byte, error)
- func Get(rawurl string) ([]byte, error)
- func Head(rawurl string) ([]byte, error)
- func Patch(rawurl string, body []byte) ([]byte, error)
- func Post(rawurl string, body []byte) ([]byte, error)
- func Put(rawurl string, body []byte) ([]byte, error)
- type FetchConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Fetch ¶
func Fetch(fc FetchConfig) ([]byte, error)
Fetch makes a request, caches its response, and returns the response body. By default, the cache is only used for GET requests. For all other methods, fc.CacheKey must be defined
Types ¶
type FetchConfig ¶
type FetchConfig struct {
url.URL
// Method describes which request method to use.
Method string
// Body store the request's body.
Body []byte
http.Header
// Query is the url.Values form of the request's query params.
// These are to be encoded for use by URL's RawQuery.
Query url.Values
// TTL is the time to live for a request's response in cache
TTL time.Duration
// CacheKey offers an optional key to use in place of the default key.
// When defined, the response body of the request will be cached, no
// matter the Method used.
CacheKey string
}
FetchConfig holds all the information needed by dal.Fetch() to make a request.
func (*FetchConfig) NewRequest ¶ added in v0.6.0
func (fc *FetchConfig) NewRequest() (*http.Request, error)
NewRequest creates an http.Request from a FetchConfig.
func (*FetchConfig) String ¶ added in v0.6.0
func (fc *FetchConfig) String() string
String reassembles the URL and Query into a valid URL string.