Documentation
¶
Overview ¶
Package fakehttp provides a HTTP server to serve hard-coded responses for unit tests.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewServer ¶
func NewServer(r []HardCodedResponse) *httptest.Server
NewServer returns a new FakeServer with a new web server object.
Types ¶
type FakeServer ¶
type FakeServer struct {
Responses []HardCodedResponse
}
FakeServer defines a fake HTTP server returning a set of hard-coded responses.
func (*FakeServer) ServeHTTP ¶
func (f *FakeServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type HardCodedResponse ¶
type HardCodedResponse struct { StatusCode int // Optional - HTTP status code eg. http.StatusOK RequestEscapedPath string // Optional - if present compare to request URL RequestBody string // Optional - if present compare to request body RequestMethod string // Optional - method, default GET Response []byte // Response to send back to client }
HardCodedResponse defines a static response from a FakeServer.
Click to show internal directories.
Click to hide internal directories.