mockapi

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: MIT Imports: 6 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteJSON

func WriteJSON(w http.ResponseWriter, status int, body any)

Types

type Request

type Request struct {
	Method   string
	Path     string
	Token    string
	TenantID string
	Body     []byte
}

Request is one recorded call, captured before dispatch so tests can assert on exactly what the CLI sent.

type Server

type Server struct {
	*httptest.Server
	// contains filtered or unexported fields
}

Server is a canned-response Management API double. Unrouted paths return a FastAPI-style 404 ({"detail": "Not Found"}), matching the real backend.

func New

func New() *Server

func (*Server) Handle

func (s *Server) Handle(method, path string, status int, body any)

Handle registers a canned JSON response for METHOD path.

func (*Server) HandleFunc

func (s *Server) HandleFunc(method, path string, h http.HandlerFunc)

HandleFunc registers a custom handler for METHOD path.

func (*Server) Requests

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

Requests returns a copy of all recorded requests.

func (*Server) RequestsTo

func (s *Server) RequestsTo(method, path string) []Request

RequestsTo returns the recorded requests matching METHOD path.

Jump to

Keyboard shortcuts

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