httpsink

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2026 License: MIT Imports: 8 Imported by: ? 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

Overview

Package httpsink is a local HTTP endpoint for tests: it answers every request with a fixed status and keeps what it received, so a test drives a component through its real HTTP client and checks the request it sent.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Unreachable

func Unreachable(tb testing.TB) string

Unreachable returns the URL of an endpoint that is not listening: a call to it fails with "connection refused". The port is fixed, not a closed test server, because the port of a closed server is soon given to another one.

Types

type Request

type Request struct {
	Header http.Header
	Method string
	Path   string
	Query  string
	Body   string
}

Request is what the sink received.

type Sink

type Sink struct {
	URL string
	// contains filtered or unexported fields
}

Sink is a running endpoint; it stops with the test.

func New

func New(tb testing.TB, status int) *Sink

New starts an endpoint that answers every request with the status.

func (*Sink) Requests

func (s *Sink) Requests() []Request

Requests returns the requests received so far, oldest first.

Jump to

Keyboard shortcuts

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