go-rest-client

module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: MIT

README

Go REST Client

This client should simplify rest client creation by encapsulating common functionality required for all REST requests.

Usage

First define objects for the api requests and responses:

type DogList struct {
    Data []Dog `json:"data,omitempty"`
}

type Dog struct {
    Id    string `json:"id,omitempty"`
    Breed string `json:"breed,omitempty"`
}

The declare a client and

logger := stdr.New(nil)
// stdr.SetVerbosity(4)
cli := client.NewRestClient("https://dogapi.dog/api/v2")
cli.SetLogger(&logger)

ctx := client.NewRequestContextJson[interface{}, DogList](cli)

dogList := DogList{}
status, statusCode, err := ctx.Get("breeds", nil, &dogList)
fmt.Println(status, statusCode)
if err != nil {
	panic(err)
}

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL