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

https://github.com/bozd4g/go-http-client

An enhanced and lightweight http client for Golang
https://github.com/bozd4g/go-http-client

go golang helper http http-client

Last synced: about 1 month ago
JSON representation

An enhanced and lightweight http client for Golang

Awesome Lists containing this project

README

        



go-http-client


go-http-client


An enhanced http client for Golang


Documentation on go.dev 🔗






Coverage


awesome

This package provides you a http client package for your http requests. You can send requests quicly with this package. If you want to contribute this package, please fork and [create](https://github.com/bozd4g/go-http-client/pulls) a pull request.

## Installation
```
$ go get -u github.com/bozd4g/go-http-client/
```

## Example Usage
```go
package main

import (
"context"
"log"

gohttpclient "github.com/bozd4g/go-http-client"
)

type Post struct {
ID int `json:"id"`
Title string `json:"title"`
}

func main() {
ctx := context.Background()
client := gohttpclient.New("https://jsonplaceholder.typicode.com")

response, err := client.Get(ctx, "/posts/1")
if err != nil {
log.Fatalf("error: %v", err)
}

var post Post
if err := response.Unmarshal(&post); err != nil {
log.Fatalf("error: %v", err)
}

log.Printf(post.Title) // sunt aut facere repellat provident occaecati...
}
```

## License
Copyright (c) 2020 Furkan Bozdag

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.