mock

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package mock serves an OpenAPI mock over HTTP (sonde mock): the net/http side of openapi.Mock, which chooses and renders responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(m *openapi.Mock, opt Options) http.Handler

Handler returns the mock's HTTP handler.

func Serve

func Serve(stop <-chan struct{}, ln net.Listener, h http.Handler) error

Serve serves h on ln until stop is closed, then shuts down gracefully: no new connections, in-flight requests get shutdownGrace to finish. It returns nil after a requested shutdown.

Types

type Options

type Options struct {
	// ValidateRequests answers a request that does not match its
	// operation with a 415 or 422 problem instead of a response.
	ValidateRequests bool
	// CORS answers preflight requests and allows any origin.
	CORS bool
	// Log receives one line per request and generator warnings (nil:
	// none). Bodies are never logged.
	Log io.Writer
}

Options configure the handler.

Jump to

Keyboard shortcuts

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