103 lines
2.6 KiB
Go
103 lines
2.6 KiB
Go
|
// Code generated by goa v3.6.0, DO NOT EDIT.
|
||
|
//
|
||
|
// Service1 client HTTP transport
|
||
|
//
|
||
|
// Command:
|
||
|
// $ goa gen goa_example/design
|
||
|
|
||
|
package client
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
"net/http"
|
||
|
|
||
|
goahttp "goa.design/goa/v3/http"
|
||
|
goa "goa.design/goa/v3/pkg"
|
||
|
)
|
||
|
|
||
|
// Client lists the Service1 service endpoint HTTP clients.
|
||
|
type Client struct {
|
||
|
// Signin Doer is the HTTP client used to make requests to the signin endpoint.
|
||
|
SigninDoer goahttp.Doer
|
||
|
|
||
|
// Secure Doer is the HTTP client used to make requests to the secure endpoint.
|
||
|
SecureDoer goahttp.Doer
|
||
|
|
||
|
// RestoreResponseBody controls whether the response bodies are reset after
|
||
|
// decoding so they can be read again.
|
||
|
RestoreResponseBody bool
|
||
|
|
||
|
scheme string
|
||
|
host string
|
||
|
encoder func(*http.Request) goahttp.Encoder
|
||
|
decoder func(*http.Response) goahttp.Decoder
|
||
|
}
|
||
|
|
||
|
// NewClient instantiates HTTP clients for all the Service1 service servers.
|
||
|
func NewClient(
|
||
|
scheme string,
|
||
|
host string,
|
||
|
doer goahttp.Doer,
|
||
|
enc func(*http.Request) goahttp.Encoder,
|
||
|
dec func(*http.Response) goahttp.Decoder,
|
||
|
restoreBody bool,
|
||
|
) *Client {
|
||
|
return &Client{
|
||
|
SigninDoer: doer,
|
||
|
SecureDoer: doer,
|
||
|
RestoreResponseBody: restoreBody,
|
||
|
scheme: scheme,
|
||
|
host: host,
|
||
|
decoder: dec,
|
||
|
encoder: enc,
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Signin returns an endpoint that makes HTTP requests to the Service1 service
|
||
|
// signin server.
|
||
|
func (c *Client) Signin() goa.Endpoint {
|
||
|
var (
|
||
|
encodeRequest = EncodeSigninRequest(c.encoder)
|
||
|
decodeResponse = DecodeSigninResponse(c.decoder, c.RestoreResponseBody)
|
||
|
)
|
||
|
return func(ctx context.Context, v interface{}) (interface{}, error) {
|
||
|
req, err := c.BuildSigninRequest(ctx, v)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = encodeRequest(req, v)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
resp, err := c.SigninDoer.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, goahttp.ErrRequestError("Service1", "signin", err)
|
||
|
}
|
||
|
return decodeResponse(resp)
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Secure returns an endpoint that makes HTTP requests to the Service1 service
|
||
|
// secure server.
|
||
|
func (c *Client) Secure() goa.Endpoint {
|
||
|
var (
|
||
|
encodeRequest = EncodeSecureRequest(c.encoder)
|
||
|
decodeResponse = DecodeSecureResponse(c.decoder, c.RestoreResponseBody)
|
||
|
)
|
||
|
return func(ctx context.Context, v interface{}) (interface{}, error) {
|
||
|
req, err := c.BuildSecureRequest(ctx, v)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
err = encodeRequest(req, v)
|
||
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
resp, err := c.SecureDoer.Do(req)
|
||
|
if err != nil {
|
||
|
return nil, goahttp.ErrRequestError("Service1", "secure", err)
|
||
|
}
|
||
|
return decodeResponse(resp)
|
||
|
}
|
||
|
}
|