This package provides a generic go
client template for an HTTP API
go-http-client
is compatible with modern Go releases in module mode, with Go installed:
go get github.com/NdoleStudio/go-http-client
Alternatively the same can be achieved if you use import
in a package:
import "github.com/NdoleStudio/go-http-client"
- Status Codes
GET /200
: OK
An instance of the client can be created using New()
.
package main
import (
"github.com/NdoleStudio/go-http-client"
)
func main() {
statusClient := client.New(client.WithDelay(200))
}
All API calls return an error
as the last return object. All successful calls will return a nil
error.
status, response, err := statusClient.Status.Ok(context.Background())
if err != nil {
//handle error
}
status, response, err := statusClient.Status.Ok(context.Background())
if err != nil {
log.Fatal(err)
}
log.Println(status.Description) // OK
You can run the unit tests for this client from the root directory using the command below:
go test -v
This project is licensed under the MIT License - see the LICENSE file for details