luci: go.chromium.org/luci/gce/appengine/testing/roundtripper Index | Files

package roundtripper

import "go.chromium.org/luci/gce/appengine/testing/roundtripper"

Package roundtripper contains http.RoundTripper implementations suitable for testing.

Index

Package Files

roundtripper.go

type JSONRoundTripper Uses

type JSONRoundTripper struct {
    // Handler is called by RoundTrip with the unmarshalled JSON from an *http.Request.
    // Returns an HTTP status code and an interface{} to marshal as JSON in an *http.Response.
    Handler func(interface{}) (int, interface{})
    // Type is the reflect.Type to unmarshal *http.Request.Body into.
    // Defaults to map[string]string{}.
    Type reflect.Type
}

JSONRoundTripper implements http.RoundTripper to handle *http.Requests with a JSON body.

func (*JSONRoundTripper) RoundTrip Uses

func (t *JSONRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip handles an *http.Request with a JSON body, returning an *http.Response with a JSON body. Panics on error. Implements http.RoundTripper.

type StringRoundTripper Uses

type StringRoundTripper struct {
    // Handler is called by RoundTrip.
    // Returns an HTTP status code and a string to return in an *http.Response.
    Handler func(*http.Request) (int, string)
}

StringRoundTripper implements http.RoundTripper to handle *http.Requests.

func (*StringRoundTripper) RoundTrip Uses

func (t *StringRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip handles an *http.Request, returning an *http.Response with a string body. Panics on error. Implements http.RoundTripper.

Package roundtripper imports 7 packages (graph). Updated 2019-06-12. Refresh now. Tools for package owners.