httpclient

package module
v2.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package httpclient provides http client used for SDK.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*gclient.Client
	// contains filtered or unexported fields
}

Client is an http client for SDK.

func New

func New(config Config) *Client

New creates and returns an http client for SDK.

func (*Client) Get

func (c *Client) Get(ctx context.Context, path string, in, out interface{}) error

Get sends a request using GET method.

func (*Client) Request

func (c *Client) Request(ctx context.Context, req, res interface{}) error

Request sends request to service by struct object `req`, and receives response to struct object `res`.

type Config

type Config struct {
	URL     string          `v:"required"` // Service address. Eg: user.svc.local, http://user.svc.local
	Client  *gclient.Client // Custom underlying client.
	Logger  *glog.Logger    // Custom logger.
	RawDump bool            // Whether auto dump request&response in stdout.
}

Config is the configuration struct for SDK client.

Jump to

Keyboard shortcuts

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