Skip to content
/ ghttp Public
forked from winterssy/ghttp

A simple, user-friendly and concurrent safe HTTP request library for Go

License

Notifications You must be signed in to change notification settings

lhmwzy/ghttp

 
 

Repository files navigation

ghttp

ghttp is a simple, user-friendly and concurrent safe HTTP request library for Go.

Build codecov Go Report Card GoDoc License

Features

ghttp wraps net/http and provides convenient APIs and advanced features to simplify your jobs.

  • Requests-style APIs.
  • GET, POST, PUT, PATCH, DELETE, etc.
  • Easy set query params, headers and cookies.
  • Easy send form, JSON or multipart payload.
  • Automatic cookies management.
  • Backoff retry mechanism.
  • Before request and after response callbacks.
  • Rate limiting for outbound requests.
  • Easy decode the response body to bytes, string or unmarshal the JSON-encoded data.
  • Friendly debugging.
  • Concurrent safe.

Install

go get -u github.com/winterssy/ghttp

Usage

import "github.com/winterssy/ghttp"

Quick Start

The usages of ghttp are very similar to net/http .

  • ghttp.Client
client := ghttp.New()
// Now you can manipulate client like net/http
client.CheckRedirect = ghttp.NoRedirect
client.Timeout = 300 * time.Second
  • ghttp.Request
req, err := ghttp.NewRequest("GET", "https://httpbin.org/get")
if err != nil {
    log.Fatal(err)
}
// Now you can manipulate req like net/http
req.Close = true
  • ghttp.Response
resp, err := ghttp.Get("https://www.google.com")
if err != nil {
    log.Fatal(err)
}
// Now you can access resp like net/http
fmt.Println(resp.StatusCode)

Documentation is available at go.dev .

License

MIT

About

A simple, user-friendly and concurrent safe HTTP request library for Go

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 100.0%