mockapi

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 6 Imported by: 0

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