bling

package module
v0.0.0-...-b608fe9 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2017 License: Apache-2.0 Imports: 7 Imported by: 0

README

Bling

Bling is a Go HTTP client library for creating and sending API requests written in Golang/Go.

bling Logo

Build Status

Bling has cool methods which simplify setting HTTP Request properties and sending request. Check usage or the examples to learn how to use Bling in your code.

We're still under active development, adding support methods for retries, callbacks, etc.

Features
  • Method Setters: Get/Post/Put/Patch/Delete/Head
  • Adding Request Headers
  • Encode structs into URL query parameters

Install

go get github.com/blinghttp/bling

Usage

Use Bling client to set request properties and easily send http request

blingClient := bling.New() //use's default http client if .Client(customClient) is not used
resp, err := blingClient.Get("https://github.com/blinghttp/bling").DoRaw() //DoRaw method returns raw http response
if err != nil {
    fmt.Println("Some err", err)
    return
}
defer resp.Body.Close()
responseBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
    fmt.Println("Some err", err)
    return
}
fmt.Println(string(responseBody))

Contributing

We love PR's and highly encourage to contribute.

License

Apache License

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bling

type Bling struct {
	HTTPClient HTTPClient
}

func New

func New() *Bling

func (*Bling) Client

func (b *Bling) Client(client HTTPClient) *Bling

func (*Bling) Delete

func (b *Bling) Delete(pathUrl string) *Request

func (*Bling) Get

func (b *Bling) Get(pathUrl string) *Request

func (*Bling) Head

func (b *Bling) Head(pathUrl string) *Request

func (*Bling) Patch

func (b *Bling) Patch(pathUrl string) *Request

func (*Bling) Post

func (b *Bling) Post(pathUrl string) *Request

func (*Bling) Put

func (b *Bling) Put(pathUrl string) *Request

func (*Bling) Verb

func (b *Bling) Verb(verb string) *Request

type CheckRetry

type CheckRetry func(resp *http.Response, err error) (bool, error)

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient is an interface for testing a request object.

type Request

type Request struct {
	// contains filtered or unexported fields
}

all the backoff ans try managers will go here

func NewRequest

func NewRequest(client HTTPClient, verb string) *Request

func (*Request) Body

func (r *Request) Body(obj interface{}) *Request

func (*Request) Do

func (r *Request) Do() Result

func (*Request) DoRaw

func (r *Request) DoRaw() (*http.Response, error)

func (*Request) GetHttpRequest

func (r *Request) GetHttpRequest() (*http.Request, error)

func (*Request) Path

func (r *Request) Path(path string) *Request

func (*Request) SetHeader

func (r *Request) SetHeader(key, value string) *Request

func (*Request) URL

func (r *Request) URL() string

type Result

type Result struct {
	// contains filtered or unexported fields
}

func (Result) Has2xxStatus

func (r Result) Has2xxStatus() bool

func (Result) Into

func (r Result) Into(successObj, errorObj interface{}) error

func (Result) StatusCode

func (r Result) StatusCode(statusCode *int) Result

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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