util

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AsanaHost = "https://app.asana.com"

	ContentType = "application/json"

	HttpGetMethod  = "GET"
	HttpPutMethod  = "PUT"
	HttpPostMethod = "POST"

	AsanaDateFormat = "2006-01-02"
)

Variables

View Source
var (
	AsanaHeaders = make(map[string]string)
)

Functions

func Request

func Request(req *http.Request) ([]byte, error)

func SetNetworkCfg

func SetNetworkCfg(cfg Network)

Types

type Body

type Body interface {
	BuildRequest() []byte
}

type Bytes

type Bytes []byte

func (Bytes) BuildRequest

func (self Bytes) BuildRequest() []byte

type Client

type Client struct {
	GatewayURL    string
	URI           string
	Headers       map[string]string
	Authorization string
	Method        string
	HTTPStatus    int
	Body          []byte // Indicates both Request Body & Response Body
	TraceId       interface{}
}

func NewHttpClient

func NewHttpClient(url, uri, m string, b []byte) *Client

url, uri, method, body

func (*Client) AddHeader

func (c *Client) AddHeader(k, v string)

func (*Client) BuildRequest

func (c *Client) BuildRequest(body Body)

func (*Client) Print

func (c *Client) Print()

func (*Client) Request

func (c *Client) Request() (err error)

type Network

type Network struct {
	Env            string   `toml:"env"`
	Host           []string `toml:"gateway"`
	GatewayURL     string
	RequestTimeout time.Duration `toml:"request_timeout"`
	ConnectTimeout time.Duration `toml:"connect_timeout"`
	SocketTimeout  time.Duration `toml:"socket_timeout"`
}

Network contains common configuration.

Jump to

Keyboard shortcuts

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