Documentation
¶
Index ¶
- Variables
- func ContextWithRequestID(parent context.Context, requestID string) context.Context
- func ErrorStatus(err error) int
- func RequestIDFromContext(ctx context.Context) (string, bool)
- type APIv1
- func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)
- func (s *APIv1) NewRequest(ctx context.Context, method, path string, data interface{}, params *url.Values) (req *http.Request, err error)
- func (s *APIv1) Status(ctx context.Context) (out *StatusReply, err error)
- type Client
- type ClientOption
- type PageQuery
- type Reply
- type StatusError
- type StatusReply
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func ContextWithRequestID ¶
Adds a request ID to the context which is sent with the request in the X-Request-ID header.
func ErrorStatus ¶
ErrorStatus returns the HTTP status code from an error or 500 if the error is not a StatusError.
Types ¶
type APIv1 ¶
type APIv1 struct {
// contains filtered or unexported fields
}
APIv1 implements the v1 Client interface for making requests to the TRISA SHN.
func (*APIv1) Do ¶
func (s *APIv1) Do(req *http.Request, data interface{}, checkStatus bool) (rep *http.Response, err error)
Do executes an http request against the server, performs error checking, and deserializes the response data into the specified struct.
func (*APIv1) NewRequest ¶
type Client ¶
type Client interface {
Status(context.Context) (*StatusReply, error)
}
Client defines the service interface for interacting with the Exchequer service internal API (e.g. the API that users can integrate with).
type ClientOption ¶
ClientOption allows us to configure the APIv1 client when it is created.
func WithClient ¶
func WithClient(client *http.Client) ClientOption
type PageQuery ¶
type PageQuery struct {
PageSize int `json:"page_size,omitempty" url:"page_size,omitempty" form:"page_size"`
NextPageToken string `json:"next_page_token" url:"next_page_token,omitempty" form:"next_page_token"`
PrevPageToken string `json:"prev_page_token" url:"prev_page_token,omitempty" form:"prev_page_token"`
}
PageQuery manages paginated list requests.
type Reply ¶
type Reply struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
Version string `json:"version,omitempty"`
}
Reply contains standard fields that are used for generic API responses and errors.
type StatusError ¶
StatusError decodes an error response from the TRISA API.
func (*StatusError) Error ¶
func (e *StatusError) Error() string
type StatusReply ¶
type StatusReply struct {
Status string `json:"status"`
Uptime string `json:"uptime,omitempty"`
Version string `json:"version,omitempty"`
}
Returned on status requests.