Documentation
¶
Overview ¶
Package requests is a wrapper around net/http with less public global variables
Package requests wrap net/http like requests did for python it is easy to use, but not very efficient
Index ¶
- Constants
- Variables
- func ExtractBasicAuth(val string) (username string, password string, err error)
- func ExtractBasicAuthFromRequest(r *http.Request) (string, string, error)
- func GenerateBasicAuth(username string, password string) string
- func GetJSON(url string, data interface{}) error
- func GetJSONStringMap(url string) (map[string]string, error)
- func NewDefaultClient() *http.Client
- func NewDefaultTransport() *http.Transport
- type Client
- func (c *Client) Get(url string) (*Response, error)
- func (c *Client) GetJSON(url string, data interface{}) error
- func (c *Client) GetJSONStringMap(url string) (map[string]string, error)
- func (c *Client) Post(url string, data io.Reader) (*Response, error)
- func (c *Client) PostBytes(url string, data []byte) (*Response, error)
- func (c *Client) PostString(url string, data string) (*Response, error)
- type Response
Constants ¶
const ( ShadowSocksLocal = "127.0.0.1:1080" ContentJSON = "application/json" )
const AuthorizationHeader = "Authorization"
NOTE: net/http already implemented it https://golang.org/pkg/net/http/#Request.BasicAuth
Variables ¶
var TransportBuilder transportBuilder
TODO: might switch to functional options https://dave.cheney.net/2014/10/17/functional-options-for-friendly-apis TODO: http proxy? might just use environment variable? https://stackoverflow.com/questions/14661511/setting-up-proxy-for-http-client TransportBuilder is the initial builder, its method use value receiver and return a new copy for chaining and keep itself unchanged
Functions ¶
func ExtractBasicAuth ¶
func GenerateBasicAuth ¶
func NewDefaultClient ¶ added in v0.0.5
NewDefaultClient returns a client using NewDefaultTransport
func NewDefaultTransport ¶ added in v0.0.5
NewDefaultTransport is copied from net/http/transport.go
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}