/restful

Simple golang rest client

Primary LanguageGoBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

restful - a very simple wrapper around restful clients in golang

Provides basic backoff and stats reporting facilities.

import "github.com/MediaMath/restful

func main() {

    type foo struct {
        Foo int `json:"foo"`
    }

    client := restful.WithExpectedResult(http.DefaultClient, http.StatusOK)

    fooResponse := &foo{}
    status, body, err := restful.DoJSON(client, http.NewRequest("GET", "http://example.com", nil), fooResponse)

    if err != nil || fooResponse.Foo != 98 {
	log.Fatal("Incorrect", status, body, err)
    }
}