Documentation
¶
Overview ¶
Package api provides a micro api client
Index ¶
- Constants
- type Client
- func (client *Client) Call(service, endpoint string, request, response interface{}) error
- func (client *Client) Handle(service, endpoint string) http.Handler
- func (client *Client) SetAddress(a string)
- func (client *Client) SetTimeout(d time.Duration)
- func (client *Client) SetToken(t string)
- func (client *Client) Stream(service, endpoint string, request interface{}) (*Stream, error)
- type Options
- type Request
- type Response
- type Stream
Constants ¶
View Source
const (
// Address for api
DefaultAddress = "http://localhost:8080"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client enables generic calls to micro
func (*Client) SetAddress ¶
SetAddress sets the api address
func (*Client) SetTimeout ¶
SetTimeout sets the http client's timeout
type Options ¶
type Options struct {
// JWT token for authentication
Token string
// Address of the micro api
Address string
// set a request timeout
Timeout time.Duration
}
Options of the Client
type Request ¶
type Request struct {
// eg. "helloworld"
Service string `json:"service"`
// eg. "Call"
Endpoint string `json:"endpoint"`
// json and then base64 encoded body
Body string `json:"body"`
}
Request is the request of the generic `api-client` call
type Response ¶
type Response struct {
// json and base64 encoded response body
Body string `json:"body"`
// error fields. Error json example
// {"id":"code":500,"detail":"malformed method name: \"\"","status":"Internal Server Error"}
Code int `json:"code"`
ID string `json:"id"`
Detail string `json:"detail"`
Status string `json:"status"`
}
Response is the response of the generic `api-client` call.
Click to show internal directories.
Click to hide internal directories.