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
- Host: GitHub
- URL: https://github.com/bozd4g/go-http-client
- Owner: bozd4g
- License: mit
- Created: 2019-12-14T11:22:19.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-01-28T19:25:34.000Z (about 1 year ago)
- Last Synced: 2024-07-31T20:52:37.401Z (9 months ago)
- Topics: go, golang, helper, http, http-client
- Language: Go
- Homepage:
- Size: 4.22 MB
- Stars: 76
- Watchers: 3
- Forks: 14
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-go - go-http-client - Make http calls simply and easily. (Networking / HTTP Clients)
- zero-alloc-awesome-go - go-http-client - Make http calls simply and easily. (Networking / HTTP Clients)
- awesome-ccamel - bozd4g/go-http-client - An enhanced and lightweight http client for Golang (Go)
- awesome-go-extra - go-http-client - 12-14T11:22:19Z|2021-05-02T18:35:32Z| (Networking / HTTP Clients)
README
go-http-client
An enhanced http client for GolangThis 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 mainimport (
"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 BozdagPermission 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.