Documentation
¶
Index ¶
- type Builder
- func (f *Builder) Add() *Builder
- func (f *Builder) Base(url string) *Builder
- func (f *Builder) Connect() *Builder
- func (f *Builder) ContentType(contentType string) *Builder
- func (f *Builder) Del() *Builder
- func (f *Builder) Delete() *Builder
- func (f *Builder) Get() *Builder
- func (f *Builder) Head() *Builder
- func (f *Builder) Header(key string, values ...string) *Builder
- func (f *Builder) HeadersFrom(source interface{}) *Builder
- func (f *Builder) Make() (*http.Request, error)
- func (f *Builder) Method(method string) *Builder
- func (f *Builder) New(method, url string) *Builder
- func (f *Builder) Options() *Builder
- func (f *Builder) Patch() *Builder
- func (f *Builder) Path(path string) *Builder
- func (f *Builder) Post() *Builder
- func (f *Builder) Put() *Builder
- func (f *Builder) QueryParameter(key string, values ...string) *Builder
- func (f *Builder) QueryParametersFrom(source interface{}) *Builder
- func (f *Builder) Remove() *Builder
- func (f *Builder) Set() *Builder
- func (f Builder) String() string
- func (f *Builder) Trace() *Builder
- func (f *Builder) UserAgent(userAgent string) *Builder
- func (f *Builder) Variable(key string, value interface{}) *Builder
- func (f *Builder) VariablesFrom(source interface{}) *Builder
- func (f *Builder) WithEntity(entity io.Reader) *Builder
- func (f *Builder) WithJSONEntity(entity interface{}) *Builder
- func (f *Builder) WithXMLEntity(entity interface{}) *Builder
- type Tag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder is the HTTP request builder; it can be used to create child request factories, with specialised BaseURLs or other parameters; when a sub-builder is generated, it will share the Method and BaseURL by value and all other firlds by pointer, so any change in sub-factories will affect the parent too.
func New ¶
New returns a new request builder; the URL can be omitted and specified later via Base() or Path().
func (*Builder) Add ¶
Add is used to provide a fluent API by which it is possible to add query parameters and headers without having many different methods or intermediate objects; this method relies on an internal Builder field (named op), which will be set to the "add" value and will instruct the following QueryParameter() and Header() methods to add the passed values to the current set for the given key.
func (*Builder) Base ¶
Base sets the base URL. If you intend to extend the url with Path, the URL should be specified with a trailing slash.
func (*Builder) ContentType ¶
ContentType sets the content type information in the request builder; the previous value is discarded.
func (*Builder) Del ¶
Del is used to provide a fluent API by which it is possible to replace query parameters and headers without having many different methods or intermediate objects; this method relies on an internal Builder field (named op), which will be set to the "set" value and will instruct the following QueryParameter() and Header() methods to replace the current set of values for the given key with the passed values.
func (*Builder) Header ¶
Header adds, sets or removes the given set of values to the URL's headers; if the header is being removed, there is no need to specify any value; if the header is being reset, the key is regarded as a regular expression.
func (*Builder) HeadersFrom ¶
HeadersFrom adds, sets or removes values extracted from a struct (and tagged with "header") or from a map[string][]string to the URL's headers; if the headers are being removed, there is no need to specify any value in the input struct/map; if the headers are being reset, the keys are regarded as regular expressions.
func (*Builder) Make ¶
Make creates a new http.Request from the information available in the Builder.
func (*Builder) New ¶
New clones the current builder and can optionally specify the request method and/or the request URL.
func (*Builder) Path ¶
Path overrides the builder URL; absolute and relative URLs can be used. TODO: improve documentation showing relative paths
func (*Builder) QueryParameter ¶
QueryParameter adds, sets or removes the given set of values to the URL's query parameters; if the query parameter is being removed, there is no need to specify any value; if the query parameter is being reset, the key is regarded as a regular expression.
func (*Builder) QueryParametersFrom ¶
QueryParametersFrom adds, sets or removes values extracted from a struct (and tagged with "parameter") or from a map[string][]string to the URL's query parameters; if the query parameters are being removed, there is no need to specify any value in the input struct/map; if the query parameters are being reset, the keys are regarded as regular expressions.
func (*Builder) Remove ¶
Remove is used to provide a fluent API by which it is possible to remove the values of query parameters and headers whose keys match a regular exception.
func (*Builder) Set ¶
Set is used to provide a fluent API by which it is possible to replace query parameters and headers without having many different methods or intermediate objects; this method relies on an internal Builder field (named op), which will be set to the "set" value and will instruct the following QueryParameter() and Header() methods to replace the current set of values for the given key with the passed values.
func (*Builder) UserAgent ¶
UserAgent sets the user agent information in the request builder; the previous value is discarded.
func (*Builder) Variable ¶
Variable adds, sets or removes the given value to the URL's variables; if the variable is being removed, there is no need to specify the value; both setting and adding a value for a given variable effectively replace its value.
func (*Builder) VariablesFrom ¶
VariablesFrom adds/sets or removes values extracted from a struct (and tagged with "variable") or from a map[string]string to the URL's variables; if the variables are being removed, there is no need to specify any value in the input struct/map; if the variables are being reset, the keys are regarded as regular expressions.
func (*Builder) WithEntity ¶
WithEntity sets the io.Reader from which the request body (payload) will be read; if nil is passed, the request will have no payload; the Content-Type MUST be provoded separately.
func (*Builder) WithJSONEntity ¶
WithJSONEntity sets an io.Reader that returns a JSON fragment as per the input struct; if no Content-Type has been set already, the method will automatically set it to "application/json".
func (*Builder) WithXMLEntity ¶
WithXMLEntity sets an io.Reader that returns an XML fragment as per the input struct; if no Content-Type has been set already, the method will automatically set it to "application/xml".
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Tag represents the value of a tag on a tagged struct field.
func (Tag) IsIgnore ¶
IsIgnore returns whether the tagged field struct contains the "-" (dash) character that is usually employed to say that the field should be ignored with respect to this specific tag handling (e.g. `json:"-"` means "do not marshal when writing to JSON).
func (Tag) IsMissing ¶
IsMissing returns whether the tag on the field is missing/invalid (i.e. empty).
func (Tag) IsOmitEmpty ¶
IsOmitEmpty returns whether the tag should be ignored when it contains an empty value (e.g. a null pointer).