httputil

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 18, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteJSON

func DeleteJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

DeleteJSON ...

func DeleteXML

func DeleteXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

DeleteXML ...

func GetBasicAuth

func GetBasicAuth(r *http.Request) (username, password string)

GetBasicAuth returns basic auth info

func GetBodyJSON

func GetBodyJSON(r *http.Request, v interface{}) error

GetBodyJSON returns the post json body

func GetBodyXML

func GetBodyXML(r *http.Request, v interface{}) error

GetBodyXML returns the post xml body

func GetJSON

func GetJSON(ctx context.Context, url string, headers map[string]string, res interface{}) error

GetJSON ...

func GetParam

func GetParam(r *http.Request, name string) string

GetParam returns url parameter as string

func GetParamBool

func GetParamBool(r *http.Request, name string) bool

GetParamBool returns url parameter as boolean

func GetParamInt

func GetParamInt(r *http.Request, name string) (int, error)

GetParamInt ...

func GetXML

func GetXML(ctx context.Context, url string, headers map[string]string, res interface{}) error

GetXML ...

func PostJSON

func PostJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

PostJSON ...

func PostXML

func PostXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

PostXML ...

func PutJSON

func PutJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

PutJSON ...

func PutXML

func PutXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

PutXML ...

func Request

func Request(ctx context.Context, method, url string, headers map[string]string, body io.Reader) (*http.Response, error)

Request ...

func RequestJSON

func RequestJSON(ctx context.Context, method, url string, headers map[string]string, req interface{}, res interface{}) (err error)

RequestJSON ...

func RequestXML

func RequestXML(ctx context.Context, method, url string, headers map[string]string, req interface{}, res interface{}) (err error)

RequestXML ...

Types

type HTTPUtil added in v0.1.2

type HTTPUtil interface {

	// GetParam returns url parameter as string
	GetParam(r *http.Request, name string) string
	// GetParamBool returns url parameter as boolean
	GetParamBool(r *http.Request, name string) bool
	// GetParamInt ...
	GetParamInt(r *http.Request, name string) (int, error)
	// GetBodyJSON returns the post json body
	GetBodyJSON(r *http.Request, v interface{}) error
	// GetBodyXML returns the post xml body
	GetBodyXML(r *http.Request, v interface{}) error
	// GetBasicAuth returns basic auth info
	GetBasicAuth(r *http.Request) (username, password string)

	// Request ...
	Request(ctx context.Context, method, url string, headers map[string]string, body io.Reader) (*http.Response, error)

	// RequestJSON ...
	RequestJSON(ctx context.Context, method, url string, headers map[string]string, req interface{}, res interface{}) (err error)
	// GetJSON ...
	GetJSON(ctx context.Context, url string, headers map[string]string, res interface{}) error
	// PostJSON ...
	PostJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error
	// PutJSON ...
	PutJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error
	// DeleteJSON ...
	DeleteJSON(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error

	// RequestXML ...
	RequestXML(ctx context.Context, method, url string, headers map[string]string, req interface{}, res interface{}) (err error)
	// GetXML ...
	GetXML(ctx context.Context, url string, headers map[string]string, res interface{}) error
	// PostXML ...
	PostXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error
	// PutXML ...
	PutXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error
	// DeleteXML ...
	DeleteXML(ctx context.Context, url string, headers map[string]string, req interface{}, res interface{}) error
}

HTTPUtil interface

var Default HTTPUtil = &httputil{}

Default default single for http utility

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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