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

README

尝试使用新的版本

Curl

curl请求。
  • Client:封装http.Client.修饰http.Client。处理请求过程加入一些必要的自定义处理。如:慢请求记录
  • Request:接口类型。构建并返回http.Request
  • Response:封装http.Response.修饰http.Response。集成一些常用的处理响应内容方法。如:ToJson() 返回json格式内容

TODO

1、加上熔断模式机制?

Documentation

Overview

curl包

func Curl(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"
)

Variables

This section is empty.

Functions

func Curl

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

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

func CurlWithClient

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

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

func HttpCurl

func HttpCurl(config HttpConfig) (resp *client.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 {
	client.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

Directories

Path Synopsis
client 包 @author cbping
client 包 @author cbping

Jump to

Keyboard shortcuts

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