history

package
v0.2.20 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package history provides request history management with persistence, filtering, and display formatting capabilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatHistoryItem

func FormatHistoryItem(item models.HistoricalHttpRequest, index int) string

FormatHistoryItem formats a history item for display (1-based index for users)

func SortByTime

func SortByTime(items []models.HistoricalHttpRequest)

SortByTime sorts history items by time (newest first)

func SortByURL

func SortByURL(items []models.HistoricalHttpRequest)

SortByURL sorts history items by URL alphabetically

Types

type Formatter added in v0.2.10

type Formatter struct {
	// FormatIndex formats the index number (e.g., "[1]")
	FormatIndex func(index int) string
	// FormatMethod formats the HTTP method
	FormatMethod func(method string) string
	// FormatTime formats the timestamp in dim/muted style
	FormatTime func(timeStr string) string
}

Formatter handles history display formatting

func DefaultFormatter added in v0.2.10

func DefaultFormatter() *Formatter

DefaultFormatter returns a formatter with no colors

func (*Formatter) FormatDetails added in v0.2.10

func (f *Formatter) FormatDetails(item models.HistoricalHttpRequest) string

FormatDetails formats full details of a history item

func (*Formatter) FormatItem added in v0.2.10

func (f *Formatter) FormatItem(item models.HistoricalHttpRequest, index int) string

FormatItem formats a history item for display

func (*Formatter) FormatStats added in v0.2.10

func (f *Formatter) FormatStats(stats HistoryStats) string

FormatStats formats history statistics

type HistoryManager

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

HistoryManager manages request history

func NewHistoryManager

func NewHistoryManager(dataDir string) (*HistoryManager, error)

NewHistoryManager creates a new history manager

func NewHistoryManagerWithFS added in v0.2.10

func NewHistoryManagerWithFS(fs filesystem.FileSystem, dataDir string) (*HistoryManager, error)

NewHistoryManagerWithFS creates a new history manager with a custom file system. This is primarily useful for testing.

func (*HistoryManager) Add

func (h *HistoryManager) Add(request *models.HttpRequest) error

Add adds a request to history

func (*HistoryManager) Clear

func (h *HistoryManager) Clear() error

Clear clears all history

func (*HistoryManager) GetAll

GetAll returns all history items

func (*HistoryManager) GetByIndex

func (h *HistoryManager) GetByIndex(index int) (*models.HistoricalHttpRequest, error)

GetByIndex returns a history item by index (0-based internally, but error message shows 1-based for user)

func (*HistoryManager) GetRecent

func (h *HistoryManager) GetRecent(n int) []models.HistoricalHttpRequest

GetRecent returns the most recent n items

func (*HistoryManager) GetStats

func (h *HistoryManager) GetStats() HistoryStats

GetStats returns statistics about the history

func (*HistoryManager) Remove

func (h *HistoryManager) Remove(index int) error

Remove removes a history item by index

type HistoryStats

type HistoryStats struct {
	TotalRequests int
	MethodCounts  map[string]int
	DomainCounts  map[string]int
	OldestRequest time.Time
	NewestRequest time.Time
}

HistoryStats returns statistics about the history

Jump to

Keyboard shortcuts

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