sling

package module
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2021 License: MIT Imports: 6 Imported by: 0

README

Sling

Go Go Reference

This is a fork of dghubble/sling. The purpose is for learning.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sling

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

Sling is an HTTP request builder and response receiver

func New

func New(httpClient slinghttp.Client) *Sling

New return barebone Sling

func (*Sling) AddHeader added in v1.4.0

func (s *Sling) AddHeader(key, value string) *Sling

func (*Sling) AddQueries added in v1.4.0

func (s *Sling) AddQueries(qs ...interface{}) *Sling

func (*Sling) AddQuery added in v1.4.0

func (s *Sling) AddQuery(q interface{}) *Sling

func (*Sling) BaseURL added in v1.6.0

func (s *Sling) BaseURL(baseURL string) *Sling

BaseURL set base URL Leave empty if error

func (*Sling) BodyForm

func (s *Sling) BodyForm(data interface{}) *Sling

func (*Sling) BodyJSON

func (s *Sling) BodyJSON(data interface{}) *Sling

func (*Sling) BodyProvider

func (s *Sling) BodyProvider(bodyProvider slinghttp.BodyProvider) *Sling

func (*Sling) Clone added in v1.4.0

func (s *Sling) Clone() (*Sling, error)

Clone return Sling with same values All values are copied except HTTP client so that change in the clone will not affect the original

func (*Sling) Connect added in v1.2.0

func (s *Sling) Connect(pathURL string) *Sling

func (*Sling) Delete

func (s *Sling) Delete(pathURL string) *Sling

func (*Sling) Get

func (s *Sling) Get(pathURL string) *Sling

func (*Sling) HTTPClient added in v1.4.0

func (s *Sling) HTTPClient(client slinghttp.Client) *Sling

HTTPClient set HTTP client Fallback to http.DefaultClient

func (*Sling) Head

func (s *Sling) Head(pathURL string) *Sling

func (*Sling) Method added in v1.4.0

func (s *Sling) Method(method, pathURL string) *Sling

func (*Sling) Options added in v1.2.0

func (s *Sling) Options(pathURL string) *Sling

func (*Sling) Patch

func (s *Sling) Patch(pathURL string) *Sling

func (*Sling) PathURL added in v1.6.0

func (s *Sling) PathURL(pathURL string) *Sling

PathURL add path URL to base URL Base URL: example.com Path URL: /users Result: example.com/users

func (*Sling) Post

func (s *Sling) Post(pathURL string) *Sling

func (*Sling) Put

func (s *Sling) Put(pathURL string) *Sling

func (*Sling) Receive

func (s *Sling) Receive(v interface{}) error

Receive decode response body to v

func (*Sling) Request

func (s *Sling) Request() (*http.Request, error)

Request return internal HTTP request

func (*Sling) ResponseDecoder added in v1.4.0

func (s *Sling) ResponseDecoder(rspDecoder slinghttp.ResponseDecoder) *Sling

func (*Sling) SetHeader added in v1.4.0

func (s *Sling) SetHeader(key, value string) *Sling

func (*Sling) Trace added in v1.2.0

func (s *Sling) Trace(pathURL string) *Sling

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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