debug

package
v1.75.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 13 Imported by: 0 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

Overview

Package debug provides a Unix socket-based HTTP server and client for runtime debugging and inspection. The server exposes internal state and allows runtime operations via HTTP endpoints over a local socket.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client communicates with a debug Server over a Unix domain socket using HTTP. All requests are routed through the socket; the HTTP host is ignored by the transport.

func NewClient

func NewClient(socketPath string) (*Client, error)

NewClient creates a Client that connects to the debug server at the given Unix socket path. Returns an error if the socket file does not exist.

func (*Client) Close

func (c *Client) Close()

Close releases transport resources held by the underlying HTTP client.

func (*Client) Get

func (c *Client) Get(ctx context.Context, paths ...string) ([]byte, error)

Get sends a GET request to the debug server. Path segments are joined to form the URL. Returns the response body or an error if the request fails or the server returns a non-2xx status.

type Server

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

Server provides a Unix socket HTTP server for debugging endpoints. Use Register() to add custom debug endpoints that can be accessed via curl --unix-socket.

func NewServer

func NewServer(logger *log.Logger) *Server

NewServer creates a new debug server with panic recovery middleware. The server won't start listening until Start() is called.

func (*Server) Register

func (s *Server) Register(method string, url string, handler func(http.ResponseWriter, *http.Request))

Register adds a debug endpoint handler for the specified HTTP method and URL path. Currently, supports GET and POST methods. Other methods are silently ignored.

Example: server.Register(http.MethodGet, "/status", statusHandler)

func (*Server) Start

func (s *Server) Start(socketPath string) error

Start creates and binds to a Unix socket, then starts the HTTP server in a goroutine. If the socket file already exists, it will be removed and recreated.

Example access: curl --unix-socket /path/to/socket http://localhost/endpoint

Jump to

Keyboard shortcuts

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