Help us shape the future of Go! Take the 2026 Go Developer Survey

devproxy

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheStatus

type CacheStatus struct {
	Dirty               bool   `json:"dirty"`
	FallbackScanEnabled bool   `json:"fallback_scan_enabled"`
	Fingerprint         string `json:"fingerprint"`
	LastBuildAt         string `json:"last_build_at,omitempty"`
	LastError           string `json:"last_error,omitempty"`
	OverlayCount        int    `json:"overlay_count"`
	RebuildCount        uint64 `json:"rebuild_count"`
	StaleServedCount    uint64 `json:"stale_served_count"`
	WatchEnabled        bool   `json:"watch_enabled"`
	WatchError          string `json:"watch_error,omitempty"`
}

CacheStatus exposes runtime cache metadata for diagnostics.

type Config

type Config struct {
	APIURL            string
	Debug             bool
	DevToken          string
	EventsJSON        bool
	ExcludeRules      []string
	Host              string
	IncludeRules      []string
	MaxBodyBytes      int64
	Port              int
	QuietRequests     bool
	Site              string
	TemplateRoot      string
	UseColor          bool
	UserAgent         string
	Watch             bool
	WatchScanInterval time.Duration
}

Config controls proxy server behavior.

type Logger

type Logger struct {
	DebugEnabled bool
	EventsJSON   bool
	UseColor     bool
	// contains filtered or unexported fields
}

Logger provides human and structured runtime output.

func (*Logger) Debug

func (l *Logger) Debug(message string, fields map[string]any)

func (*Logger) Info

func (l *Logger) Info(message string, fields map[string]any)

func (*Logger) Warn

func (l *Logger) Warn(message string, fields map[string]any)

type Matcher

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

Matcher decides whether a request should be handled by the simulator proxy.

func NewMatcher

func NewMatcher(include []string, exclude []string) Matcher

NewMatcher builds a matcher from route rule strings.

func (Matcher) ShouldProxy

func (m Matcher) ShouldProxy(method string, path string, isWebsocket bool) bool

ShouldProxy returns true when the request should be sent to simulator/render.

type Server

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

Server hosts the local simulator proxy.

func New

func New(config Config, client SimulatorClient) (*Server, error)

func (*Server) Errors

func (s *Server) Errors() <-chan error

func (*Server) Start

func (s *Server) Start() error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

func (*Server) URL

func (s *Server) URL() string

type SimulatorClient

type SimulatorClient interface {
	SimulatorRender(ctx context.Context, payload api.SimulatorPayload) (*api.SimulatorResponse, error)
}

SimulatorClient is the API client dependency for simulator render calls.

type TemplateCache

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

TemplateCache caches compressed template payloads and invalidates on changes.

func NewTemplateCache

func NewTemplateCache(root string, watchEnabled bool, scanInterval time.Duration, logger *Logger) *TemplateCache

func (*TemplateCache) GetCompressed

func (c *TemplateCache) GetCompressed() (code string, stale bool, err error)

GetCompressed returns compressed template payload. stale=true indicates stale cache served due to rebuild error.

func (*TemplateCache) SetOverlays added in v0.1.13

func (c *TemplateCache) SetOverlays(overlays []TemplateOverlay) error

func (*TemplateCache) Start

func (c *TemplateCache) Start() error

func (*TemplateCache) Status

func (c *TemplateCache) Status() CacheStatus

func (*TemplateCache) Stop

func (c *TemplateCache) Stop() error

type TemplateOverlay added in v0.1.13

type TemplateOverlay struct {
	Content string `json:"content"`
	Path    string `json:"path"`
	Type    string `json:"type"`
}

TemplateOverlay is an in-memory template replacement supplied by the local dev server.

Jump to

Keyboard shortcuts

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