Documentation
¶
Overview ¶
Package reqlog provides a live HTTP request dashboard for Go web applications. It captures every request hitting your server and displays them in a real-time browser dashboard with full request/response inspection, latency tracking, and replay.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct {
Port int // Dashboard port (default: 9000)
MaxRequests int // Max entries in ring buffer (default: 200)
SlowThreshold int // Latency threshold in ms to flag slow requests (default: 200)
AutoOpen bool // Auto-open browser on start (default: true)
AllowInProd bool // Allow running in production (default: false)
AllowNetwork bool // Allow network access to the dashboard (default: false, only localhost)
}
Options configures the reqlog instance.
type Reqlog ¶
type Reqlog struct {
// contains filtered or unexported fields
}
Reqlog is the main reqlog instance that runs the dashboard server and provides middleware.
func (*Reqlog) ChiMiddleware ¶
ChiMiddleware returns a Chi-compatible middleware. Chi uses the standard net/http middleware signature, so this is an alias for Middleware().
func (*Reqlog) GinMiddleware ¶
func (r *Reqlog) GinMiddleware() gin.HandlerFunc
GinMiddleware returns a Gin middleware that captures requests and responses.
func (*Reqlog) IsBlocked ¶
IsBlocked returns true if reqlog is blocked (e.g. production mode without AllowInProd).
func (*Reqlog) Middleware ¶
Middleware returns a standard net/http middleware that captures requests and responses.
func (*Reqlog) Port ¶
Port returns the actual port the dashboard is listening on, or 0 if not started.
type ReqlogEntry ¶
type ReqlogEntry struct {
ID string `json:"id"`
Timestamp int64 `json:"timestamp"`
Method string `json:"method"`
URL string `json:"url"`
StatusCode int `json:"statusCode"`
Latency int64 `json:"latency"`
Slow bool `json:"slow"`
RequestHeaders map[string]string `json:"requestHeaders"`
ResponseHeaders map[string]string `json:"responseHeaders"`
RequestBody any `json:"requestBody"`
ResponseBody any `json:"responseBody"`
AppHost string `json:"appHost"`
}
ReqlogEntry represents a captured HTTP request/response pair.
func (ReqlogEntry) GetID ¶
func (e ReqlogEntry) GetID() string
GetID implements the ID interface for ReqlogEntry.
type RingBuffer ¶
type RingBuffer[T interface{ GetID() string }] struct {
// contains filtered or unexported fields
}
RingBuffer is a thread-safe circular buffer that overwrites the oldest entries when full.
func NewRingBuffer ¶
func NewRingBuffer[T interface{ GetID() string }](capacity int) *RingBuffer[T]
NewRingBuffer creates a new ring buffer with the given capacity.
func (*RingBuffer[T]) FindByID ¶
func (rb *RingBuffer[T]) FindByID(id string) (T, bool)
FindByID finds an item by its ID. Returns the item and true if found.
func (*RingBuffer[T]) Push ¶
func (rb *RingBuffer[T]) Push(item T)
Push adds an item to the buffer, overwriting the oldest if full.
func (*RingBuffer[T]) ToSlice ¶
func (rb *RingBuffer[T]) ToSlice() []T
ToSlice returns all items in order from oldest to newest.