Documentation
¶
Index ¶
- Variables
- func Do(ctx context.Context, method, url string, data interface{}) (*http.Response, error)
- func DoRequest(r *http.Request) (*http.Response, error)
- func Parse(resp *http.Response, val interface{}) error
- func ParseHeaders(resp *http.Response, val interface{}) error
- func ParseJsonBody(resp *http.Response, val interface{}) error
- type App
- type AppClient
- type Option
- type Service
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrGetWithBody = errors.New("HTTP GET should not have body")
ErrGetWithBody indicates that GET request with body.
Functions ¶
func Do ¶
Do sends an HTTP request with the given arguments and returns an HTTP response. data is automatically marshal into a *httpRequest, typically it's defined in an API file.
func ParseHeaders ¶
ParseHeaders parses the response headers.
func ParseJsonBody ¶
ParseJsonBody parses the response body, which should be in json content type.
Types ¶
type AppClient ¶
type AppClient interface {
WithHeader(header map[string]string) AppClient
WithQuery(query map[string]string) AppClient
WithData(data interface{}) AppClient
DisabledReqLog() AppClient
DisabledReplyLog() AppClient
Post(uri string, reply interface{}) (AppClient, error)
PostCtx(ctx context.Context, uri string, reply interface{}) (AppClient, error)
Get(uri string, reply interface{}) (AppClient, error)
GetCtx(ctx context.Context, uri string, reply interface{}) (AppClient, error)
Put(uri string, reply interface{}) (AppClient, error)
PutCtx(ctx context.Context, uri string, reply interface{}) (AppClient, error)
Delete(uri string, reply interface{}) (AppClient, error)
DeleteCtx(ctx context.Context, uri string, reply interface{}) (AppClient, error)
HttpCode() int
}
type Service ¶
type Service interface {
// Do sends an HTTP request with the given arguments and returns an HTTP response.
Do(ctx context.Context, method, url string, data interface{}) (*http.Response, error)
// DoRequest sends a HTTP request to the service.
DoRequest(r *http.Request) (*http.Response, error)
}
Service represents a remote HTTP service.
func NewService ¶
NewService returns a remote service with the given name. opts are used to customize the *http.Client.
Click to show internal directories.
Click to hide internal directories.