curl

package
v0.0.0-...-da45c02 Latest Latest
Warning

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

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

Documentation

Overview

curl包

func Do(url, method string, params, header map[string]string, body []byte) (resBody map[string]interface{}, resHeader map[string][]string, responseStatus string)

Index

Constants

View Source
const (
	GET    = "GET"
	POST   = "POST"
	PUT    = "PUT"
	DELETE = "DELETE"
	HEAD   = "HEAD"
)
View Source
const (
	ContentTypeJson = "application/json"

	ContentTypeFormDate = "application/x-www-form-urlencoded"
)

Variables

This section is empty.

Functions

func Do

func Do(url, method string, params, header map[string]string, body []byte) (resp *core.Response, err error)

@url string 请求Uri @method string 方法。GET,POST,PUT等 @params map[string]string 参数。?a=b @header map[string]string 头部信息 @body []byte @notice 建议使用 HttpCurl

func DoWithClient

func DoWithClient(url, method string, params, header map[string]string, body []byte, c *core.Client) (resp *core.Response, err error)

自定义的client执行curl请求 @Deprecated 建议使用 HttpCurl

func HttpCurl

func HttpCurl(config HttpConfig) (resp *core.Response, err error)

http 请求

Types

type HttpConfig

type HttpConfig struct {

	// 方法。GET,POST,PUT等
	Method string
	// 请求Uri
	Url string
	// query 参数
	Params map[string]string
	// body内容 from或者json
	Data    map[string]string
	Headers map[string]string
	// 如果Body不为nil,则会覆盖Data数据,也就是说Body优先级高于Data
	Body []byte
	// contains filtered or unexported fields
}

http config

type Request

type Request struct {
	core.BaseRequest
	// http config
	HttpConfig
}

请求 实现Request接口

func (*Request) HttpRequest

func (curl *Request) HttpRequest() (req *http.Request, err error)

func (*Request) String

func (curl *Request) String() string

Jump to

Keyboard shortcuts

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