httptest

package
v3.14.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	JsonContentType   = "application/json"
	FormEncodedType   = "application/x-www-form-urlencoded"
	ContentTypeHeader = "Content-Type"
)

Variables

This section is empty.

Functions

func GetBody

func GetBody(body io.ReadCloser) []byte

Types

type RequestTester

type RequestTester struct {
	Delay         string `json:"delay"`
	DelayDuration time.Duration
	DelayOnCall   int `json:"delay_on_call"`
}

type Responder

type Responder struct {
	Body      string              `json:"body"`
	CallCount int                 `json:"call_count"`
	Method    string              `json:"method"`
	Error     string              `json:"error"`
	Headers   map[string][]string `json:"headers"`
	Path      string              `json:"path"`
}

type TestServer

type TestServer struct {
	Server    *httptest.Server
	URL       string
	CallCount int
	Mutex     sync.Mutex
}

func NewTestServer

func NewTestServer(statusCode int) *TestServer

func (*TestServer) Close

func (ts *TestServer) Close()

func (*TestServer) GetCalls

func (ts *TestServer) GetCalls(delta int) int

Jump to

Keyboard shortcuts

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