http

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ContentTypeTextXml = "text/xml"
	ContentTypeHtml    = "text/html; charset=utf-8"
	ContentTypeTextCss = "text/css; charset=utf-8"
	ContentTypeXJS     = "application/x-javascript"
	ContentTypeJS      = "text/javascript"
	ContentTypeJson    = "application/json; charset=utf-8"
	ContentTypeForm    = "application/x-www-form-urlencoded"
	ContentTypeImg     = "image/png"
)

Functions

func BasicAuthRequest

func BasicAuthRequest(method, url string, body io.Reader, deadline, dialTimeout time.Duration, header map[string]string, username, password string) ([]byte, int, error)

BasicAuthRequest - send an http Request

func CookiesGet

func CookiesGet(url string, deadline, dialTimeout time.Duration, header map[string]string) ([]byte, []*http.Cookie, error)

CookiesGet - send an http get Request, response cookies

func GetRequestWithBasicAuth

func GetRequestWithBasicAuth(url string, deadline, dialTimeout time.Duration, username, password string) ([]byte, int, error)

GetRequestWithBasicAuth - get request with Basic Auth

func PatchJSON

func PatchJSON(url string, data interface{}, deadline, dialTimeout time.Duration) ([]byte, int, error)

PatchJSON - send an http patch json Request.

func PostForm

func PostForm(url string, data []byte, deadline, dialTimeout time.Duration) ([]byte, int, error)

PostForm - sen an http post form Request

func PostJSON

func PostJSON(url string, data interface{}, deadline, dialTimeout time.Duration) ([]byte, int, error)

PostJSON - send an http post json Request.

func Request

func Request(method, url string, body io.Reader, deadline, dialTimeout time.Duration, header map[string]string) ([]byte, int, error)

Request - send an http Request

func RequestCookies

func RequestCookies(method, url string, body io.Reader, deadline, dialTimeout time.Duration, header map[string]string, cookies []*http.Cookie) ([]byte, []*http.Cookie, error)

RequestCookies - send an http Request with cookies

func RequestWithProxy added in v1.0.2

func RequestWithProxy(method, url string, body io.Reader, deadline, dialTimeout time.Duration, header map[string]string, proxy *Proxy) ([]byte, int, error)

RequestWithProxy - send an http Request with http proxy

func SimpleDelete

func SimpleDelete(url string, deadline, dialTimeout time.Duration) ([]byte, int, error)

SimpleDelete - send an simple http delete Request

func SimpleGet

func SimpleGet(url string, deadline, dialTimeout time.Duration) ([]byte, int, error)

SimpleGet - send an http get Request

func SimplePut

func SimplePut(url string, deadline, dialTimeout time.Duration) ([]byte, int, error)

SimplePut - send an simple http put Request

Types

type HttpResponse

type HttpResponse struct {
	Code    int         `json:"Code"`
	Message string      `json:"Message"`
	Data    interface{} `json:"Data,omitempty"`
}

HttpResponse - htt Response

func NewHttpResponse

func NewHttpResponse() *HttpResponse

NewHttpResponse -

func (*HttpResponse) Error

func (h *HttpResponse) Error(err error)

Error - set Error

func (*HttpResponse) Response

func (h *HttpResponse) Response(resp http.ResponseWriter)

Response - write data to resp

func (*HttpResponse) ResponseWithErr

func (h *HttpResponse) ResponseWithErr(resp http.ResponseWriter, err error)

ResponseWithErr - write data to resp with error

type Proxy added in v1.0.2

type Proxy struct {
	URL      string `json:"url"`
	UserName string `json:"user_name"`
	Password string `json:"password"`
}

Proxy - http proxy config

type RespData

type RespData struct {
	Total int64       `json:"total"`
	Rows  interface{} `json:"rows"`
}

RespData user for bootstrap

Jump to

Keyboard shortcuts

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