README

gentleman/proxy Build Status GoDoc Go Report Card

gentleman's plugin to easily manage HTTP proxies used by clients.

Installation

go get -u gopkg.in/h2non/gentleman.v2/plugins/proxy

API

See godoc reference.

Example

package main

import (
  "fmt"
  "gopkg.in/h2non/gentleman.v2"
  "gopkg.in/h2non/gentleman.v2/plugins/proxy"
)

func main() {
  // Create a new client
  cli := gentleman.New()

  // Define a list of HTTP proxies to be used
  cli.Use(proxy.Set([]string{"http://proxy:3128", "http://proxy2:3128"}))

  // Perform the request
  res, err := cli.Request().URL("http://httpbin.org/headers").Send()
  if err != nil {
    fmt.Printf("Request error: %s\n", err)
    return
  }
  if !res.Ok {
    fmt.Printf("Invalid server response: %d\n", res.StatusCode)
    return
  }

  fmt.Printf("Status: %d\n", res.StatusCode)
  fmt.Printf("Body: %s", res.String())
}

License

MIT - Tomas Aparicio

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Set

func Set(servers map[string]string) p.Plugin

    Set defines the proxy servers to be used based on the transport scheme

    Types

    This section is empty.

    Source Files