Documentation ¶
Index ¶
- func URIEscape(path string) string
- type Client
- type Connector
- type HTTPClient
- func (client *HTTPClient) Delete(path string, opts *RequestOptions, result interface{}) error
- func (client *HTTPClient) Do(path string, opts *RequestOptions, method string, body io.Reader, ...) error
- func (client *HTTPClient) FromHTTPRequest(req *http.Request) (*HTTPClient, error)
- func (client *HTTPClient) Get(path string, opts *RequestOptions, result interface{}) error
- func (client *HTTPClient) GetOptions() Options
- func (client *HTTPClient) Head(path string, opts *RequestOptions) error
- func (client *HTTPClient) Post(path string, opts *RequestOptions, body io.Reader, result interface{}) error
- func (client *HTTPClient) Put(path string, opts *RequestOptions, body io.Reader, result interface{}) error
- func (client *HTTPClient) WithOptions(opts Options) Client
- type MissingParameter
- type NoHostConfigError
- type NoRealmConfigError
- type Options
- type Params
- type RealmConfig
- type RealmsConfig
- type Registry
- type RequestError
- type RequestOptions
- type Service
- type ServiceFactoryFunc
- type UID
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface { // GetOptions returns a copy of the current options. GetOptions() Options // WithOptions returns a new client that has new default client options. Only // non-zero values in the options argument will override the client's options. WithOptions(opts Options) Client // Get performs a GET request and provides the decoded return value in // the result argument, unless nil. Get(path string, opts *RequestOptions, result interface{}) error // Head performs a HEAD request. Its only use is really to check that // the resource does not return an error. Head(path string, opts *RequestOptions) error // Delete performs a DELETE request and provides the decoded return // value in the result argument, unless nil. Delete(path string, opts *RequestOptions, result interface{}) error // Post performs a POST request. The body can be nil if no body is to be // sent. Provides the decoded return value in the result argument, unless // nil. Post(path string, opts *RequestOptions, body io.Reader, result interface{}) error // Put performs a PUT request. The body can be nil if no body is to be // sent. Provides the decoded return value in the result argument, unless // nil. Put(path string, opts *RequestOptions, body io.Reader, result interface{}) error // Do performs an HTTP request. Do(path string, opts *RequestOptions, method string, body io.Reader, result interface{}) error }
type Connector ¶
type Connector struct {
// contains filtered or unexported fields
}
func NewConnectorFromConfig ¶
func NewConnectorFromConfig(config RealmsConfig) (*Connector, error)
func (*Connector) Connect ¶
Connect finds one or more services. The input arguments must be pointers to variables which have the same interface types as those registered with Register().
func (*Connector) Register ¶
func (connector *Connector) Register(intf interface{}, fn ServiceFactoryFunc)
Register registers a new service. The type must be a nil interface pointer; e.g. (*MyInterface)(nil). The function is a factory function that takes a client, and must return a new service instance.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient is a client for the Central API.
func NewHTTPClient ¶
func NewHTTPClient(opts Options) (*HTTPClient, error)
NewHTTPClient constructs a new client.
func (*HTTPClient) Delete ¶
func (client *HTTPClient) Delete(path string, opts *RequestOptions, result interface{}) error
func (*HTTPClient) Do ¶
func (client *HTTPClient) Do( path string, opts *RequestOptions, method string, body io.Reader, result interface{}) error
func (*HTTPClient) FromHTTPRequest ¶
func (client *HTTPClient) FromHTTPRequest(req *http.Request) (*HTTPClient, error)
FromHTTPRequest constructs a new client that inherits the host name, protocol, session and request ID from an HTTP request. Any options specified will override inferred from the request.
func (*HTTPClient) Get ¶
func (client *HTTPClient) Get(path string, opts *RequestOptions, result interface{}) error
func (*HTTPClient) GetOptions ¶
func (client *HTTPClient) GetOptions() Options
func (*HTTPClient) Head ¶
func (client *HTTPClient) Head(path string, opts *RequestOptions) error
func (*HTTPClient) Post ¶
func (client *HTTPClient) Post(path string, opts *RequestOptions, body io.Reader, result interface{}) error
func (*HTTPClient) Put ¶
func (client *HTTPClient) Put(path string, opts *RequestOptions, body io.Reader, result interface{}) error
func (*HTTPClient) WithOptions ¶
func (client *HTTPClient) WithOptions(opts Options) Client
type MissingParameter ¶
type MissingParameter struct {
Key string
}
func (*MissingParameter) Error ¶
func (err *MissingParameter) Error() string
type NoHostConfigError ¶
type NoHostConfigError struct {
Host string
}
func (*NoHostConfigError) Error ¶
func (err *NoHostConfigError) Error() string
type NoRealmConfigError ¶
type NoRealmConfigError struct {
Realm string
}
func (*NoRealmConfigError) Error ¶
func (err *NoRealmConfigError) Error() string
type Options ¶
type Options struct { // ServiceName of target application. ServiceName string // APIVersion of target application. Defaults to 1. APIVersion int // Host is the host name, optionally including the port, to connect to. Host string // Protocol is the HTTP protocol. Defaults to "http". Protocol string // HTTPClient is an optional HTTP client instance, which will be used // instead of the default. HTTPClient *http.Client // Session is an optional Checkpoint session key. Session string // RequestID is an optional request ID that can be passed on to the service. RequestID string // Logger is an optional interface to permit instrumentation. Ignored if // passing in a custom HTTP client. Logger httplogger.HTTPLogger // Ctx is an optional context. Ctx context.Context }
Options contains options for the client.
type Params ¶
type Params map[string]interface{}
Params is a map of query parameters.
type RealmConfig ¶
type RealmConfig struct { // Host for this realm. Host string `json:"host" yaml:"host"` // Aliases valid for this realm. Aliases []string `json:"aliases" yaml:"aliases"` // Session key. Session string `json:"session" yaml:"session"` }
func (*RealmConfig) ClientOptions ¶
func (config *RealmConfig) ClientOptions() Options
type RealmsConfig ¶
type RealmsConfig map[string]*RealmConfig
func (RealmsConfig) FindByHost ¶
func (c RealmsConfig) FindByHost(host string) *RealmConfig
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) GetFactoryFunc ¶
func (registry *Registry) GetFactoryFunc(ptr interface{}) (ServiceFactoryFunc, error)
type RequestError ¶
type RequestError struct { Options *RequestOptions Req *http.Request Resp *http.Response PartialBody []byte // contains filtered or unexported fields }
func (*RequestError) Error ¶
func (err *RequestError) Error() string
type RequestOptions ¶
type RequestOptions struct { // Params is an optional map of query parameters. Params Params }
RequestOptions is a set of options that can be applied to a request.