httpserver

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package httpserver provides a configurable mock HTTP server for testing and development purposes. It allows users to define request matching rules and dynamic templated responses via configuration files. Features include support for request sequencing, custom headers, authentication, TLS, and advanced response templating.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	*output.Options
	TLSCertificate      string        // TLS certificate file path.
	TLSKey              string        // TLS key file path.
	ReadTimeout         time.Duration // HTTP Server read timeout.
	WriteTimeout        time.Duration // HTTP Server write timeout.
	ConfigPath          string        // Config path.
	DelayParticipation  float32       // Delay participation rate (fraction of requests that will be delayed. 0.0 <= p <= 1.0).
	DelayDuration       time.Duration // Delay duration.
	FaultParticipation  float32       // Fault participation rate (fraction of requests that will fail. 0.0 <= p <= 1.0).
	FaultErrorCode      int           // Fault HTTP error code.
	ExitOnUnmatchedRule bool          // If true it will exit if a request does not match any rule.
}

Options are the options for the HTTP server.

type Server

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

Server is an HTTP server for mocking HTTP responses.

func New

func New(opts *Options, logger *zap.SugaredLogger) (*Server, error)

New creates a new HTTP server.

func (*Server) Close

func (o *Server) Close() error

Close gracefully shuts down the server without interrupting any active connections.

func (*Server) Start

func (o *Server) Start(ctx context.Context) error

Start starts the HTTP server.

Jump to

Keyboard shortcuts

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