Categorygithub.com/DCRcoder/request
modulepackage
0.0.3
Repository: https://github.com/dcrcoder/request.git
Documentation: pkg.go.dev

# README

request

A friendly HTTP request library for Golang like Python-Requests.

Installation

go get -u github.com/DCRcoder/request

Usage

import (
    "github.com/DCRcoder/request"
)

GET:

req := request.NewRequest(c)
resp, err := req.Get("http://httpbin.org/get", nil)

// 输出文本
resp.Text()

// 可以序列化为 map 或者 struct
resp.JSON(&data)

// 设置 querys
req.Get("http://httpbin.org/get", map[string]string{"test": "test"})

POST、PUT、PATCH:

// 以 post 为例
req := request.NewRequest()
// form reuqest
req.Data = map[string]string{
    "key": "value",
    "a":   "123",
}
resp, err := req.Post("http://httpbin.org/post", nil)

// json request
req.JSON = map[string]string{
    "key": "value",
    "a":   "123",
}
resp, err := req.Post("http://httpbin.org/post", nil)

Headers:

req := request.NewRequest(c)
// 设置整个 header
req.SetHeaderByMap(map[string]string{
    "Accept-Encoding": "gzip,deflate,sdch",
    "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
})
resp, err := req.Get("http://httpbin.org/get", nil)

// 设置单个 header
req.SetHeader("content", "json")

TODO

[ ] FIEL REQUEST

[ ] AUTH

[ ] HOOK

[ ] PROXY

License

Under the MIT License.

# Functions

Delete direct do delete method.
Get direct do get method.
NewRequest return new request.
ParseQueryURL 组合 url.
PatchJSON direct do patch method with json data.
PostJSON direct do post method with json data.
PutJSON direct do put method with json data.

# Constants

HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
HTTP Headers were copied from net/http.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.
MIME types that are commonly used.

# Variables

DefaultHeader 默认 header.
OBJNotCanSet obj.

# Structs

Request request 实例.
Response response 实例.