Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mozillazg/request
A developer-friendly HTTP request library for Gopher.
https://github.com/mozillazg/request
go golang http request
Last synced: about 2 months ago
JSON representation
A developer-friendly HTTP request library for Gopher.
- Host: GitHub
- URL: https://github.com/mozillazg/request
- Owner: mozillazg
- License: mit
- Created: 2014-12-21T04:30:42.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-12-05T09:11:26.000Z (over 4 years ago)
- Last Synced: 2024-04-09T23:10:17.571Z (2 months ago)
- Topics: go, golang, http, request
- Language: Go
- Homepage: https://godoc.org/github.com/mozillazg/request
- Size: 214 KB
- Stars: 426
- Watchers: 17
- Forks: 40
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Lists
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go-extra - request - friendly HTTP request library for Gopher.|418|39|6|2014-12-21T04:30:42Z|2019-12-05T09:11:26Z| (Utilities / Fail injection)
- awesome-go-cn - request
- awesome-go-zh - request
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- fucking-awesome-go - :octocat: request - Go HTTP Requests for Humans™. :star: 129 :fork_and_knife: 12 (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go-projects - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go - request - | - | - | (Utilities / HTTP Clients)
- awesome-go-zh - request
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go-cn - request
- awesome-go-stars - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go. - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / <span id="高级控制台用户界面-advanced-console-uis">高级控制台用户界面 Advanced Console UIs</span>)
- awesome-go-cn - request - Go 语言版的 HTTP Requests for Humans™. (实用工具 / 高级控制台界面)
- awesome-go-with-stars - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-stars - request - A developer-friendly HTTP request library for Gopher. (Go)
- repo-1316-awesome-go-cn - request
- repo-1211-awesome-go-cn - request
- awesome-Char - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- Go-awesome - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go-cn - request
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go-with-framework - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go-cn - request
- awesome-go-handwritten - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go - request - Go 語言版的 HTTP Requests for Humans™. (實用工具 / 高級控制台界面)
- awesome-go - request - Go HTTP Requests for Humans™. - :arrow_down:10 - :star:148 (Utilities / HTTP Clients)
- awesome-go - request - A developer-friendly HTTP request library for Gopher. - ★ 327 (Utilities)
- awesome-go2 - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Advanced Console UIs)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go-cn - request
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / Utility/Miscellaneous)
- awesome-reader - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
- go-awesome-cn-star - request
- awesome-go - request - Go HTTP Requests for Humans™. (Utilities / HTTP Clients)
README
request
=======
[![Build Status](https://travis-ci.org/mozillazg/request.svg?branch=master)](https://travis-ci.org/mozillazg/request)
[![Coverage Status](https://coveralls.io/repos/mozillazg/request/badge.png?branch=master)](https://coveralls.io/r/mozillazg/request?branch=master)
[![Go Report Card](https://goreportcard.com/badge/github.com/mozillazg/request)](https://goreportcard.com/report/github.com/mozillazg/request)
[![GoDoc](https://godoc.org/github.com/mozillazg/request?status.svg)](https://godoc.org/github.com/mozillazg/request)A developer-friendly HTTP request library for Gopher. Inspired by [Python-Requests](https://github.com/kennethreitz/requests).
Installation
------------```
go get -u github.com/mozillazg/request
```Documentation
--------------API documentation can be found here:
https://godoc.org/github.com/mozillazg/requestUsage
-------```go
import (
"github.com/mozillazg/request"
)
```**GET**:
```go
c := new(http.Client)
req := request.NewRequest(c)
resp, err := req.Get("http://httpbin.org/get")
j, err := resp.Json()
defer resp.Body.Close() // Don't forget close the response body
```**POST**:
```go
req := request.NewRequest(c)
req.Data = map[string]string{
"key": "value",
"a": "123",
}
resp, err := req.Post("http://httpbin.org/post")
```**Cookies**:
```go
req := request.NewRequest(c)
req.Cookies = map[string]string{
"key": "value",
"a": "123",
}
resp, err := req.Get("http://httpbin.org/cookies")
```**Headers**:
```go
req := request.NewRequest(c)
req.Headers = 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")
```**Files**:
```go
req := request.NewRequest(c)
f, err := os.Open("test.txt")
req.Files = []request.FileField{
request.FileField{"file", "test.txt", f},
}
resp, err := req.Post("http://httpbin.org/post")
```**Json**:
```go
req := request.NewRequest(c)
req.Json = map[string]string{
"a": "A",
"b": "B",
}
resp, err := req.Post("http://httpbin.org/post")
req.Json = []int{1, 2, 3}
resp, err = req.Post("http://httpbin.org/post")
```**Proxy**:
```go
req := request.NewRequest(c)
req.Proxy = "http://127.0.0.1:8080"
// req.Proxy = "https://127.0.0.1:8080"
// req.Proxy = "socks5://127.0.0.1:57341"
resp, err := req.Get("http://httpbin.org/get")
```
or https://github.com/mozillazg/request/tree/develop/_example/proxy**HTTP Basic Authentication**:
```go
req := request.NewRequest(c)
req.BasicAuth = request.BasicAuth{"user", "passwd"}
resp, err := req.Get("http://httpbin.org/basic-auth/user/passwd")
```License
---------Under the MIT License.