Skip to content

ICGGroup/ctxclient

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ctxclient package

GoDoc BSD 3-Clause License

Package ctxclient offers utilities for easing the making of http calls by handing boilerplate functions and providing for the selection of an http.Client/Transport based upon the current context. A ctxclient.Func provides the basis of the functionality via the Client and Do methods. A nil ctxclient simply returns the default client while a Func that return the ErrUseDefault will also return the default on a Client call.

The Do func simplifies making an http request by handling context timeouts and checking for non 2xx response. In the case of a non 2xx response a NotSuccess error is returned which contains the body, header and status code of the response.

var f ctxclient.Func

res, err = f.Do(ctx, req)
if err != nil {
    ...
}

Funcs may also be used to global defaults by registering a Func via the ctxclient.Register function.

Please review examples_test.go.

This package borrows from ideas found in golang.org/x/oauth2.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 100.0%