Version: v0.2.2 Latest Latest

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

Go to latest
Published: Oct 26, 2020 License: MIT Imports: 21 Imported by: 14




This section is empty.


This section is empty.


func CallWithResult

func CallWithResult(opt Option, result interface{}) error

CallWithResult sends request and set result.

func DebugOff

func DebugOff()

DebugOff deactivates request debugging.

func DebugOn

func DebugOn()

DebugOn activates request debugging.


type Method

type Method string

Method is HTTP Method.

const (
	MethodGET    Method = "GET"
	MethodPOST   Method = "POST"
	MethodPUT    Method = "PUT"
	MethodDELETE Method = "DELETE"

HTTP method list.

func (Method) String

func (m Method) String() string

type Option

type Option struct {
	URL       string
	Method    Method
	Headers   map[string]string
	Timeout   time.Duration
	Retry     bool
	Debug     bool
	Plugins   []plugin.Plugin
	UserAgent string

	// Basic Auth
	User string
	Pass string

	// Authorization Bearer:
	Bearer string

	// Query Parameter
	Query interface{}

	// Body Parameter
	Payload interface{}
	// PayloadType is used for body payload type
	PayloadType PayloadType

	// Custom content-type
	ContentType string

Option is wrapper struct of http option

type PayloadType

type PayloadType string

PayloadType is payload type for POST

var (
	PayloadTypeBODY   PayloadType = "BODY"
	PayloadTypeJSON   PayloadType = "JSON"
	PayloadTypeXML    PayloadType = "XML"
	PayloadTypeFORM   PayloadType = "FORM"
	PayloadTypeDATA   PayloadType = "DATA"
	PayloadTypeSTREAM PayloadType = "STREAM"

POST Payload type variables

type Response

type Response struct {

Response is wrapper struct of *gentleman.Response

func Call

func Call(opt Option) (*Response, error)

Call sneds HTTP request by given option.


func DELETE(url string, opt Option) (*Response, error)

DELETE sends DELETE request with option.

func GET

func GET(url string, opt Option) (*Response, error)

GET sends GET request with option.

func POST

func POST(url string, opt Option) (*Response, error)

POST sends POST request with option.

func PUT

func PUT(url string, opt Option) (*Response, error)

PUT sends PUT request with option.

func (Response) HasStatusCodeError added in v0.1.1

func (r Response) HasStatusCodeError() error

HasStatusCodeError returns error if HTTP status code is not 2xx code.


Path Synopsis

Jump to

Keyboard shortcuts

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