Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndolestudio/go-http-client
Template for building HTTP API clients in Go
https://github.com/ndolestudio/go-http-client
api-client go go-api-client golang
Last synced: about 1 month ago
JSON representation
Template for building HTTP API clients in Go
- Host: GitHub
- URL: https://github.com/ndolestudio/go-http-client
- Owner: NdoleStudio
- License: mit
- Created: 2021-11-20T11:37:07.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-08-30T13:54:38.000Z (over 1 year ago)
- Last Synced: 2024-06-20T03:32:40.361Z (7 months ago)
- Topics: api-client, go, go-api-client, golang
- Language: Go
- Homepage:
- Size: 12.7 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-http-client
[![Build](https://github.com/NdoleStudio/go-http-client/actions/workflows/main.yml/badge.svg)](https://github.com/NdoleStudio/go-http-client/actions/workflows/main.yml)
[![codecov](https://codecov.io/gh/NdoleStudio/go-http-client/branch/main/graph/badge.svg)](https://codecov.io/gh/NdoleStudio/go-http-client)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/NdoleStudio/go-http-client/badges/quality-score.png?b=main)](https://scrutinizer-ci.com/g/NdoleStudio/go-http-client/?branch=main)
[![Go Report Card](https://goreportcard.com/badge/github.com/NdoleStudio/go-http-client)](https://goreportcard.com/report/github.com/NdoleStudio/go-http-client)
[![GitHub contributors](https://img.shields.io/github/contributors/NdoleStudio/go-http-client)](https://github.com/NdoleStudio/go-http-client/graphs/contributors)
[![GitHub license](https://img.shields.io/github/license/NdoleStudio/go-http-client?color=brightgreen)](https://github.com/NdoleStudio/go-http-client/blob/master/LICENSE)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/NdoleStudio/go-http-client)](https://pkg.go.dev/github.com/NdoleStudio/go-http-client)This package provides a generic `go` client template for an HTTP API
## Installation
`go-http-client` is compatible with modern Go releases in module mode, with Go installed:
```bash
go get github.com/NdoleStudio/go-http-client
```Alternatively the same can be achieved if you use `import` in a package:
```go
import "github.com/NdoleStudio/go-http-client"
```## Implemented
- [Status Codes](#status-codes)
- `GET /200`: OK## Usage
### Initializing the Client
An instance of the client can be created using `New()`.
```go
package mainimport (
"github.com/NdoleStudio/go-http-client"
)func main() {
statusClient := client.New(client.WithDelay(200))
}
```### Error handling
All API calls return an `error` as the last return object. All successful calls will return a `nil` error.
```go
status, response, err := statusClient.Status.Ok(context.Background())
if err != nil {
//handle error
}
```### Status Codes
#### `GET /200`: OK
```go
status, response, err := statusClient.Status.Ok(context.Background())if err != nil {
log.Fatal(err)
}log.Println(status.Description) // OK
```## Testing
You can run the unit tests for this client from the root directory using the command below:
```bash
go test -v
```## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details