httprequest

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

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

Go to latest
Published: Oct 1, 2014 License: MIT Imports: 12 Imported by: 5

README

go-httprequest

A http request abstraction. Why? I kept having to write this layer over and over again. Sadly, I'm tired of having N versions/variations in various projects. I pray for this be the one http abstraction to rule them all ... for my projects.

Setup / Dependencies

$ go get github.com/mreiferson/go-httpclient
$ go get github.com/heatxsink/go-httprequest

Some Details

If you would like to use http basic auth with your http requests use the function UseBasicAuth(bool) in conjunction with setting Username and Password public variables on the HttpRequest struct.

Also if you would like to use proxy your http requests use the function UseProxy(bool) and set the ProxyUrl public variable on the HttpRequest struct.

For everything else please take a look at httprequest_test.go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpRequest

type HttpRequest struct {
	Transport     *httpclient.Transport
	Client        *http.Client
	ProxyFlag     bool
	BasicAuthFlag bool
	Username      string
	Password      string
	ProxyUrl      string
}

func New

func New(connection_timeout time.Duration, response_header_timeout time.Duration, request_timeout time.Duration, keep_alive_flag bool, compression_flag bool, skip_tls_verify bool) *HttpRequest

func NewWithDefaults

func NewWithDefaults() *HttpRequest

func (*HttpRequest) Dump

func (r *HttpRequest) Dump()

func (*HttpRequest) Get

func (r *HttpRequest) Get(url string, headers map[string]string) ([]byte, int, error)

func (*HttpRequest) PostMultipart

func (r *HttpRequest) PostMultipart(url string, headers map[string]string, multipart_params map[string]string) ([]byte, int, error)

func (*HttpRequest) PostUrlEncoded

func (r *HttpRequest) PostUrlEncoded(url string, headers map[string]string, data url.Values) ([]byte, int, error)

func (*HttpRequest) Put

func (r *HttpRequest) Put(url string, headers map[string]string, data string) ([]byte, int, error)

func (*HttpRequest) UseBasicAuth

func (r *HttpRequest) UseBasicAuth(flag bool)

func (*HttpRequest) UseProxy

func (r *HttpRequest) UseProxy(flag bool)

Jump to

Keyboard shortcuts

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