digestRequest

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT Imports: 8 Imported by: 0

README

go-digest-request - request with digest authentication in golang

CircleCI Coverage Status

Usage

  • When creating context, use digestRequest.ContextWithClient() for appengine.urlfetch in Google App Engine.
import (
  "fmt"
  "io/ioutil"
  "net/http"

  "github.com/delphinus/go-digest-request"
  "golang.org/x/net/context"
)

func main() {
  ctx := context.Background()
  r := digestRequest.New(ctx, "john", "hello") // username & password

  req, _ := http.NewRequest("GET", "http://example.com", nil)
  resp, _ := r.Do(req)
  defer resp.Body.Close()

  b, _ := ioutil.ReadAll(resp.Body)

  fmt.Println(string(b))
}

Documentation

Index

Constants

This section is empty.

Variables

View Source
var HTTPClientKey httpClientKey

HTTPClientKey will be used for a key of context

Functions

func ContextWithClient

func ContextWithClient(parent context.Context, client *http.Client) context.Context

ContextWithClient returns context with a specified *http.Client

Types

type DigestRequest

type DigestRequest struct {
	context.Context
	// contains filtered or unexported fields
}

DigestRequest is a client for digest authentication requests

func New

func New(ctx context.Context, username, password string) *DigestRequest

New makes a DigestRequest instance

func (*DigestRequest) Do

func (r *DigestRequest) Do(req *http.Request) (*http.Response, error)

Do does requests as http.Do does

Jump to

Keyboard shortcuts

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