Documentation
¶
Overview ¶
Package history provides request history management with persistence, filtering, and display formatting capabilities.
Index ¶
- func FormatHistoryItem(item models.HistoricalHttpRequest, index int) string
- func SortByTime(items []models.HistoricalHttpRequest)
- func SortByURL(items []models.HistoricalHttpRequest)
- type Formatter
- type HistoryManager
- func (h *HistoryManager) Add(request *models.HttpRequest) error
- func (h *HistoryManager) Clear() error
- func (h *HistoryManager) GetAll() []models.HistoricalHttpRequest
- func (h *HistoryManager) GetByIndex(index int) (*models.HistoricalHttpRequest, error)
- func (h *HistoryManager) GetRecent(n int) []models.HistoricalHttpRequest
- func (h *HistoryManager) GetStats() HistoryStats
- func (h *HistoryManager) Remove(index int) error
- func (h *HistoryManager) Search(query string) []models.HistoricalHttpRequest
- type HistoryStats
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) GetAll ¶
func (h *HistoryManager) GetAll() []models.HistoricalHttpRequest
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
func (*HistoryManager) Search ¶
func (h *HistoryManager) Search(query string) []models.HistoricalHttpRequest
Search searches history by URL or method