go-digest-request - request with digest authentication in golang
- 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))
}