Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nahid/gohttp

HTTP client for Go
https://github.com/nahid/gohttp

go golang http http-client request

Last synced: 29 days ago
JSON representation

HTTP client for Go

Awesome Lists containing this project

README

        

# gohttp

[![Build Status](https://travis-ci.org/nahid/gohttp.svg?branch=master)](https://travis-ci.org/nahid/gohttp)
[![Go Report Card](https://goreportcard.com/badge/github.com/nahid/gohttp)](https://goreportcard.com/report/github.com/nahid/gohttp)
[![Coverage Status](https://coveralls.io/repos/github/nahid/gohttp/badge.svg?branch=master)](https://coveralls.io/github/nahid/gohttp?branch=master)

HTTP client for Go, its also support asynchronous request

## Installation

```
go get github.com/nahid/gohttp
```

### Example

#### `POST https://httpbin.org/post`

```go
package main

import (
"github.com/nahid/gohttp"
"fmt"
)

func main() {
req := gohttp.NewRequest()

resp, err := req.
FormData(map[string]string{"name": "Nahid"}).
Post("https://httpbin.org/post")

if err != nil {
panic(err)
}

if resp.GetStatusCode() == 200 {
var resps map[string]interface{}

_ = resp.GetBodyWithUnmarshal(&resps)
fmt.Println(resps["form"])
}
}
```

#### Async Example

```go
package main

import (
"github.com/nahid/gohttp"
"fmt"
)

func main() {
req := gohttp.NewRequest()
ch := make(chan *gohttp.AsyncResponse)

var users [3]string

users[0] = "nahid"
users[1] = "shipu"
users[2] = "sujan"

for i:=0; i