request

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package request contains everything for build a http request and unpack a http response.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StringToTime

func StringToTime(timeString, format string) (time.Time, error)

StringToTime transforms given string to time.

func StringToUnixInt

func StringToUnixInt(timeString, format string) int

StringToUnixInt transforms given string to unix time int.

func TimeToString

func TimeToString(timeValue time.Time, format string) string

TimeToString transforms given time to string.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is the request builder for QingCloud service.

func (*Builder) BuildHTTPRequest

func (b *Builder) BuildHTTPRequest(o *data.Operation, i interface{}) (*http.Request, error)

BuildHTTPRequest builds http request with an operation and an input.

type Request

type Request struct {
	Operation *data.Operation
	Input     interface{}
	Output    interface{}

	HTTPRequest  *http.Request
	HTTPResponse *http.Response
}

A Request can build, sign, send and unpack API request.

func New

func New(o *data.Operation, i, x interface{}) (*Request, error)

New create a Request from given Operation, Input and Output. It returns a Request.

func (*Request) Send

func (r *Request) Send() error

Send sends API request. It returns error if error occurred.

type Signer

type Signer struct {
	AccessKeyID     string
	SecretAccessKey string

	BuiltURL string
}

Signer is the http request signer for IaaS service.

func (*Signer) BuildSignature

func (is *Signer) BuildSignature(request *http.Request) (string, error)

BuildSignature calculates the signature string.

func (*Signer) BuildStringToSign

func (is *Signer) BuildStringToSign(request *http.Request) (string, error)

BuildStringToSign build the string to sign.

func (*Signer) WriteSignature

func (is *Signer) WriteSignature(request *http.Request) error

WriteSignature calculates signature and write it to http request.

type Unpacker

type Unpacker struct {
	// contains filtered or unexported fields
}

Unpacker is the response unpacker.

func (*Unpacker) UnpackHTTPRequest

func (u *Unpacker) UnpackHTTPRequest(o *data.Operation, r *http.Response, x interface{}) (respBody string, err error)

UnpackHTTPRequest unpack the http response with an operation, http response and an output.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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