Documentation ¶
Index ¶
- Constants
- Variables
- func IsErrorResponse(res *http.Response) error
- func SetJsonAcceptHeader(req *http.Request)
- func SetJsonContentTypeHeader(req *http.Request)
- func SetRestLiHeaders(req *http.Request, method RestLiMethod)
- type Bytes
- type HostnameResolver
- type RestLiClient
- func (c *RestLiClient) DeleteRequest(url *url.URL, method RestLiMethod) (*http.Request, error)
- func (c *RestLiClient) Do(req *http.Request) (*http.Response, error)
- func (c *RestLiClient) DoAndDecode(req *http.Request, v interface{}) (res *http.Response, err error)
- func (c *RestLiClient) DoAndIgnore(req *http.Request) (res *http.Response, err error)
- func (c *RestLiClient) FormatQueryUrl(resourceBasename, rawQuery string) (*url.URL, error)
- func (c *RestLiClient) GetRequest(url *url.URL, method RestLiMethod) (*http.Request, error)
- func (c *RestLiClient) JsonPostRequest(url *url.URL, restLiMethod RestLiMethod, contents interface{}) (*http.Request, error)
- func (c *RestLiClient) JsonPutRequest(url *url.URL, restLiMethod RestLiMethod, contents interface{}) (*http.Request, error)
- func (c *RestLiClient) RawPostRequest(url *url.URL, method RestLiMethod, contents []byte) (*http.Request, error)
- type RestLiCodec
- func (r *RestLiCodec) DecodeBool(data string, v *bool) error
- func (r *RestLiCodec) DecodeBytes(data string, v *Bytes) error
- func (r *RestLiCodec) DecodeFloat32(data string, v *float32) error
- func (r *RestLiCodec) DecodeFloat64(data string, v *float64) error
- func (r *RestLiCodec) DecodeInt32(data string, v *int32) error
- func (r *RestLiCodec) DecodeInt64(data string, v *int64) error
- func (r *RestLiCodec) DecodeString(data string, v *string) error
- func (r *RestLiCodec) EncodeBool(v bool) string
- func (r *RestLiCodec) EncodeBytes(v Bytes) string
- func (r *RestLiCodec) EncodeFloat32(v float32) string
- func (r *RestLiCodec) EncodeFloat64(v float64) string
- func (r *RestLiCodec) EncodeInt32(v int32) string
- func (r *RestLiCodec) EncodeInt64(v int64) string
- func (r *RestLiCodec) EncodeString(v string) string
- type RestLiEncodable
- type RestLiError
- type RestLiMethod
- type SimpleHostnameSupplier
Constants ¶
View Source
const ( RestLiProtocolVersion = "2.0.0" RestLiHeader_Method = "X-RestLi-Method" RestLiHeader_ProtocolVersion = "X-RestLi-Protocol-Version" RestLiHeader_ErrorResponse = "X-RestLi-Error-Response" )
View Source
const ( Method_Unknown = RestLiMethod(iota) Method_get Method_create Method_delete Method_update Method_partial_update Method_batch_get Method_batch_create Method_batch_delete Method_batch_update Method_batch_partial_update Method_get_all Method_action Method_finder )
Variables ¶
View Source
var RestLiMethodNameMapping = func() map[string]RestLiMethod { mapping := make(map[string]RestLiMethod) for m := Method_get; m <= Method_finder; m++ { mapping[m.String()] = m } return mapping }()
View Source
var RestLiReducedEncoder = RestLiCodec{ // contains filtered or unexported fields }
View Source
var RestLiUrlEncoder = RestLiCodec{ // contains filtered or unexported fields }
Functions ¶
func IsErrorResponse ¶
func SetJsonAcceptHeader ¶ added in v0.7.0
func SetJsonContentTypeHeader ¶ added in v0.3.0
func SetRestLiHeaders ¶ added in v0.2.0
func SetRestLiHeaders(req *http.Request, method RestLiMethod)
Types ¶
type HostnameResolver ¶ added in v0.1.1
type HostnameResolver interface { // ResolveHostnameAndContextForQuery takes in the name of the service for which to resolve the hostname, along with // the URL for the query that is about to be sent. The service name is often the top-level parent resource's name, // but can be any unique identifier for a D2 endpoint. Some HostnameResolver implementations will choose to ignore // this parameter and resolve hostnames using a different strategy. By default, the generated code will always pass // in the top-level parent resource's name. ResolveHostnameAndContextForQuery(serviceName string, query *url.URL) (*url.URL, error) }
type RestLiClient ¶
type RestLiClient struct { *http.Client HostnameResolver }
func (*RestLiClient) DeleteRequest ¶ added in v0.7.0
func (c *RestLiClient) DeleteRequest(url *url.URL, method RestLiMethod) (*http.Request, error)
func (*RestLiClient) Do ¶
Do is a very thin shim between the standard http.Client.Do. All it does it parse the response into a RestLiError if the RestLi error header is set. A non-nil Response with a non-nil error will only occur if http.Client.Do returns such values (see the corresponding documentation). Otherwise, the response will only be non-nil if the error is nil.
func (*RestLiClient) DoAndDecode ¶ added in v0.2.0
func (c *RestLiClient) DoAndDecode(req *http.Request, v interface{}) (res *http.Response, err error)
DoAndDecode calls Do and attempts to unmarshal the response into the given value. The response body will always be read to EOF and closed, to ensure the connection can be reused.
func (*RestLiClient) DoAndIgnore ¶ added in v0.2.0
DoAndDecode calls Do and drops the response's body. The response body will always be read to EOF and closed, to ensure the connection can be reused.
func (*RestLiClient) FormatQueryUrl ¶
func (c *RestLiClient) FormatQueryUrl(resourceBasename, rawQuery string) (*url.URL, error)
func (*RestLiClient) GetRequest ¶
func (c *RestLiClient) GetRequest(url *url.URL, method RestLiMethod) (*http.Request, error)
func (*RestLiClient) JsonPostRequest ¶ added in v0.3.0
func (c *RestLiClient) JsonPostRequest(url *url.URL, restLiMethod RestLiMethod, contents interface{}) (*http.Request, error)
func (*RestLiClient) JsonPutRequest ¶ added in v0.7.0
func (c *RestLiClient) JsonPutRequest(url *url.URL, restLiMethod RestLiMethod, contents interface{}) (*http.Request, error)
func (*RestLiClient) RawPostRequest ¶ added in v0.3.0
func (c *RestLiClient) RawPostRequest(url *url.URL, method RestLiMethod, contents []byte) (*http.Request, error)
type RestLiCodec ¶
type RestLiCodec struct {
// contains filtered or unexported fields
}
func (*RestLiCodec) DecodeBool ¶ added in v0.8.1
func (r *RestLiCodec) DecodeBool(data string, v *bool) error
func (*RestLiCodec) DecodeBytes ¶
func (r *RestLiCodec) DecodeBytes(data string, v *Bytes) error
func (*RestLiCodec) DecodeFloat32 ¶ added in v0.8.1
func (r *RestLiCodec) DecodeFloat32(data string, v *float32) error
func (*RestLiCodec) DecodeFloat64 ¶ added in v0.8.1
func (r *RestLiCodec) DecodeFloat64(data string, v *float64) error
func (*RestLiCodec) DecodeInt32 ¶ added in v0.8.1
func (r *RestLiCodec) DecodeInt32(data string, v *int32) error
func (*RestLiCodec) DecodeInt64 ¶ added in v0.8.1
func (r *RestLiCodec) DecodeInt64(data string, v *int64) error
func (*RestLiCodec) DecodeString ¶
func (r *RestLiCodec) DecodeString(data string, v *string) error
func (*RestLiCodec) EncodeBool ¶ added in v0.8.1
func (r *RestLiCodec) EncodeBool(v bool) string
func (*RestLiCodec) EncodeBytes ¶
func (r *RestLiCodec) EncodeBytes(v Bytes) string
func (*RestLiCodec) EncodeFloat32 ¶ added in v0.8.1
func (r *RestLiCodec) EncodeFloat32(v float32) string
func (*RestLiCodec) EncodeFloat64 ¶ added in v0.8.1
func (r *RestLiCodec) EncodeFloat64(v float64) string
func (*RestLiCodec) EncodeInt32 ¶ added in v0.8.1
func (r *RestLiCodec) EncodeInt32(v int32) string
func (*RestLiCodec) EncodeInt64 ¶ added in v0.8.1
func (r *RestLiCodec) EncodeInt64(v int64) string
func (*RestLiCodec) EncodeString ¶
func (r *RestLiCodec) EncodeString(v string) string
type RestLiEncodable ¶
type RestLiEncodable interface { RestLiEncode(codec RestLiCodec) (data string, err error) RestLiDecode(codec RestLiCodec, data string) (err error) }
type RestLiError ¶
type RestLiError struct { Status int Message string ExceptionClass string StackTrace string FullResponse []byte `json:"-"` ResponseHeaders http.Header `json:"-"` DeserializationError error `json:"-"` }
func (*RestLiError) Error ¶
func (r *RestLiError) Error() string
type RestLiMethod ¶ added in v0.2.0
type RestLiMethod int
func (RestLiMethod) String ¶ added in v0.7.0
func (i RestLiMethod) String() string
type SimpleHostnameSupplier ¶
func (*SimpleHostnameSupplier) ResolveHostnameAndContextForQuery ¶ added in v0.7.3
Click to show internal directories.
Click to hide internal directories.