utils

package
v0.0.0-...-82ee903 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2015 License: MIT Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = 0
View Source
var LogWriter io.Writer

LogWriter for logging

Functions

func GetBodyJSON

func GetBodyJSON(resp *http.Response, i interface{})

GetBodyJSON Gets json form body

func InitLog

func InitLog()

InitLog system

func InitLogTest

func InitLogTest()

InitLogTest system

func IsDev

func IsDev() bool

func IsProd

func IsProd() bool

func IsTest

func IsTest() bool

Types

type Client

type Client struct {
	*http.Client
	BaseURL     string
	ContentType string
}

Client for http requests

func (Client) CallRequest

func (c Client) CallRequest(method string, path string, reader io.Reader) *Response

CallRequest with body

func (Client) CallRequestNoBody

func (c Client) CallRequestNoBody(method string, path string) *Response

CallRequestNoBody without body

func (Client) CallRequestNoBodytWithHeaders

func (c Client) CallRequestNoBodytWithHeaders(method string, path string, headers map[string]string) *Response

CallRequestNoBodytWithHeaders without body and with headers

func (Client) CallRequestWithHeaders

func (c Client) CallRequestWithHeaders(method string, path string, reader io.Reader, headers map[string]string) *Response

CallRequestWithHeaders with headers

type InfoExec

type InfoExec struct {
	Interface interface{}
	F         func(*http.Response) error
}

InfoExec for the MapExec

type MapExec

type MapExec map[int]InfoExec

MapExec associates status code with InfoExec

type Response

type Response struct {
	Resp *http.Response
	Err  error
}

Response wrapper

func (*Response) Solve

func (r *Response) Solve(mapExec MapExec) error

Solve with status codes

func (*Response) WithResponse

func (r *Response) WithResponse(f func(*http.Response) error) error

WithResponse Extracts response

Jump to

Keyboard shortcuts

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