transport

package
Version: v2.0.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2021 License: MIT Imports: 3 Imported by: 0

README

gentleman/transport Build Status GoDoc Go Report Card

gentleman's plugin to easily define the HTTP transport to be used by http.Client.

Installation

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

API

See godoc reference.

Example

package main

import (
  "fmt"
  "net/http"
  "gopkg.in/h2non/gentleman.v2"
  "gopkg.in/h2non/gentleman.v2/plugins/transport"
)

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

  // Define the default HTTP transport
  cli.Use(transport.Set(http.DefaultTransport))

  // 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(transport http.RoundTripper) p.Plugin

Set sets a new HTTP transport for the outgoing request

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

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