api_client

package
v0.4.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2017 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ERR_API_NAME_IS_EMPTY                    = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 1, "api name is empty")
	ERR_API_CLIENT_SEND_FAILED               = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 2, "api client send failed, api: {{.api}}, url: {{.url}}, err: {{.err}}")
	ERR_API_CLIENT_RESPONSE_UNMARSHAL_FAILED = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 3, "api response unmarshal failed, api: {{.api}}, url: {{.url}}, err: {{.err}}")

	ERR_API_CLIENT_READ_RESPONSE_BODY_FAILED = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 4, "read api response body failed, api is: {{.api}},err: {{.err}}")
	ERR_API_CLIENT_BAD_STATUS_CODE           = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 5, "bad response status code, api is: {{.api}}, code is: {{.code}}")
	ERR_API_CLIENT_CREATE_NEW_REQUEST_FAILED = errors.TN(INLET_HTTP_API_CLIENT_ERR_NS, 6, "create new request failed, err: {{.err}}")
)
View Source
var (
	DefaultClientTimeout = time.Second * 5
)
View Source
var INLET_HTTP_API_CLIENT_ERR_NS = "INLET_API_CLIENT"

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	Call(apiName string, payload spirit.Payload, v interface{}) (err error)
	Cast(apiName string, payload spirit.Payload) (err error)
}

func NewHTTPAPIClient

func NewHTTPAPIClient(url string, apiHeaderName string, timeout time.Duration) APIClient

type HTTPAPIClient

type HTTPAPIClient struct {
	// contains filtered or unexported fields
}

func (*HTTPAPIClient) Call

func (p *HTTPAPIClient) Call(apiName string, payload spirit.Payload, v interface{}) (err error)

func (*HTTPAPIClient) Cast

func (p *HTTPAPIClient) Cast(apiName string, payload spirit.Payload) (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL