httptest

package
v0.0.0-...-62d03f0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockServer

type MockServer struct {
	// contains filtered or unexported fields
}

MockServer is a simple mock server that can be used to mock HTTP responses

func NewMockServer

func NewMockServer() *MockServer

NewMockServer creates a new mock server

func (*MockServer) Close

func (m *MockServer) Close()

Close closes the mock server

func (*MockServer) GetURL

func (m *MockServer) GetURL() string

GetURL returns the URL of the mock server

func (*MockServer) Reset

func (m *MockServer) Reset()

Reset clears all the set responses

func (*MockServer) Start

func (m *MockServer) Start()

Start starts the mock server

func (*MockServer) WithGet

func (m *MockServer) WithGet(path string, response Response)

WithGet sets a response for a GET request to the given path

func (*MockServer) WithPost

func (m *MockServer) WithPost(path string, response Response)

WithPost sets a response for a POST request to the given path

type Response

type Response struct {
	StatusCode  int
	ContentType string
	Body        any
}

Response represents a response from the mock server that can be set for a given path and method

Jump to

Keyboard shortcuts

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