Documentation
¶
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) Delete(ctx context.Context, serviceName string, path string, ...) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, serviceName string, path string, ...) (*http.Response, error)
- func (c *Client) JsonDelete(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader) error
- func (c *Client) JsonGet(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader, ...) error
- func (c *Client) JsonPost(ctx context.Context, serviceName, path string, reqObj any, ...) error
- func (c *Client) JsonPut(ctx context.Context, serviceName, path string, reqObj any, ...) error
- func (c *Client) JsonRequest(ctx context.Context, serviceName, method, path string, body []byte, ...) error
- func (c *Client) Post(ctx context.Context, serviceName string, path string, body []byte, ...) (*http.Response, error)
- func (c *Client) Put(ctx context.Context, serviceName string, path string, body []byte, ...) (*http.Response, error)
- func (c *Client) Request(ctx context.Context, serviceName string, method string, path string, ...) (*http.Response, error)
- func (c *Client) XmlDelete(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader) error
- func (c *Client) XmlGet(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader, ...) error
- func (c *Client) XmlPost(ctx context.Context, serviceName, path string, reqObj any, ...) error
- func (c *Client) XmlPut(ctx context.Context, serviceName, path string, reqObj any, ...) error
- func (c *Client) XmlRequest(ctx context.Context, serviceName, method, path string, body []byte, ...) error
- type ClientConfig
- type Discovery
- type Endpoint
- type HttpStatusError
- type Part
- type UriSpec
- type ZooKeeperDiscoveryConfig
- type ZookeeperDiscovery
Constants ¶
const ( LogKeyData = "data" LogKeyError = "error" LogKeyIp = "ip" LogKeyIps = "ips" LogKeyEndpoints = "endpoints" LogKeyPath = "path" LogKeyService = "service" )
const ( HeaderAccept = "Accept" HeaderContentType = "Content-Type" )
const ( MediaJson = "application/json" MediaXml = "application/xml" )
Variables ¶
var (
ErrNoAvailableEndpoint = errors.New("no available endpoint")
)
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(config ClientConfig) *Client
func (*Client) JsonDelete ¶ added in v0.0.2
func (c *Client) JsonDelete(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader) error
JsonDelete sends a DELETE request and automatically handles JSON response unmarshalling
func (*Client) JsonGet ¶ added in v0.0.2
func (c *Client) JsonGet(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader, respObj any) error
JsonGet sends a GET request and automatically handles JSON response unmarshalling
func (*Client) JsonPost ¶ added in v0.0.2
func (c *Client) JsonPost(ctx context.Context, serviceName, path string, reqObj any, headers textproto.MIMEHeader, respObj any) error
JsonPost sends a POST request with JSON marshalling of the request body and JSON unmarshalling of the response
func (*Client) JsonPut ¶ added in v0.0.2
func (c *Client) JsonPut(ctx context.Context, serviceName, path string, reqObj any, headers textproto.MIMEHeader, respObj any) error
JsonPut sends a PUT request with JSON marshalling of the request body and JSON unmarshalling of the response
func (*Client) JsonRequest ¶ added in v0.0.2
func (c *Client) JsonRequest(ctx context.Context, serviceName, method, path string, body []byte, headers textproto.MIMEHeader, respObj any) error
JsonRequest handles making a request, sending JSON data, and automatically unmarshalling the JSON response
func (*Client) XmlDelete ¶ added in v0.1.0
func (c *Client) XmlDelete(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader) error
XmlDelete sends a DELETE request and automatically handles XML response unmarshalling
func (*Client) XmlGet ¶ added in v0.1.0
func (c *Client) XmlGet(ctx context.Context, serviceName, path string, headers textproto.MIMEHeader, respObj any) error
XmlGet sends a GET request and automatically handles XML response unmarshalling
func (*Client) XmlPost ¶ added in v0.1.0
func (c *Client) XmlPost(ctx context.Context, serviceName, path string, reqObj any, headers textproto.MIMEHeader, respObj any) error
XmlPost sends a POST request with XML marshalling of the request body and XML unmarshalling of the response
type ClientConfig ¶
type Endpoint ¶
type Endpoint struct {
Name string `json:"name"`
Id string `json:"id"`
Address string `json:"address"`
Port int `json:"port"`
SslPort *int `json:"sslPort"`
Payload interface{} `json:"payload"`
RegistrationTimeUTC int64 `json:"registrationTimeUTC"`
ServiceType string `json:"serviceType"`
UriSpec UriSpec `json:"uriSpec"`
}
type HttpStatusError ¶ added in v0.1.0
func NewHttpStatusError ¶ added in v0.1.0
func NewHttpStatusError(statusCode int, body string) *HttpStatusError
func (*HttpStatusError) Error ¶ added in v0.1.0
func (e *HttpStatusError) Error() string
func (*HttpStatusError) Is ¶ added in v0.1.0
func (e *HttpStatusError) Is(target error) bool
type ZookeeperDiscovery ¶
type ZookeeperDiscovery struct {
// contains filtered or unexported fields
}
func NewZookeeperDiscovery ¶
func NewZookeeperDiscovery(config *ZooKeeperDiscoveryConfig) (*ZookeeperDiscovery, error)
func (*ZookeeperDiscovery) Close ¶
func (z *ZookeeperDiscovery) Close() error
func (*ZookeeperDiscovery) GetEndpoints ¶
func (z *ZookeeperDiscovery) GetEndpoints(serviceName string) ([]*Endpoint, error)