HTTP Client
The einar-cli allows you to generate custom HTTP clients with the necessary files and imports to handle your outgoing calls.
📥 HTTP Resty Client installation
Inside your project directory, run the following command to include HTTP Client in your project:
einar install restyThis will generate the following files and directories within your project, setting up the necessary infrastructure for Resty HTTP Client interaction:
/app /shared /infrastructure /httpresty - client.go👨💻 Generate a New Custom HTTP Client
Inside your project directory, run the following command to create a new custom HTTP Client:
einar generate resty-client call-public-apiHere’s an example of how the generated code will look:
type CallPublicApi func(ctx context.Context, input interface{}) (interface{}, error)
func init() { ioc.Registry(NewCallPublicApi, newresty.NewClient)}func NewCallPublicApi(cli *resty.Client) CallPublicApi { return func(ctx context.Context, input interface{}) (interface{}, error) { return nil, nil }}