sitegen

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package sitegen generates static HTML documentation sites from IR traffic logs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeDedupKey

func ComputeDedupKey(record *ir.IRRecord, pathTemplate string) string

ComputeDedupKey computes a deduplication key for a request. The key is based on: method + pathTemplate + sorted query keys + body structure + status.

func DeduplicateRequests

func DeduplicateRequests(records []*StoredRecord) (distinct []*RequestView, deduped *DedupedView)

DeduplicateRequests groups requests and creates both distinct and deduped views.

func GenerateFromFile

func GenerateFromFile(inputPath, outputDir string, opts *Options) error

GenerateFromFile generates a site from an IR file or directory.

Types

type DedupedView

type DedupedView struct {
	Method              string
	PathTemplate        string
	PathParamValues     map[string][]string // param -> all seen values
	QueryParamValues    map[string][]string // param -> all seen values
	RequestBodyExample  any
	ResponseBodyExample any
	Count               int
}

DedupedView shows all variations in a compact format.

type EndpointPage

type EndpointPage struct {
	Method       string
	PathTemplate string
	Slug         string // URL-safe filename (e.g., "get-users-userid")
	RequestCount int
	StatusGroups []*StatusGroup
}

EndpointPage represents a single endpoint's page.

type Engine

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

Engine processes IR records and stores them for site generation.

func NewEngine

func NewEngine(opts *Options) *Engine

NewEngine creates a new site generation engine.

func (*Engine) BuildSiteData

func (e *Engine) BuildSiteData() *SiteData

BuildSiteData builds the SiteData from processed records.

func (*Engine) ProcessRecord

func (e *Engine) ProcessRecord(record *ir.IRRecord)

ProcessRecord processes a single IR record.

func (*Engine) ProcessRecords

func (e *Engine) ProcessRecords(records []ir.IRRecord)

ProcessRecords processes multiple IR records.

type Generator

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

Generator generates static HTML sites from IR records.

func NewGenerator

func NewGenerator(outputDir string, opts *Options) *Generator

NewGenerator creates a new site generator.

func (*Generator) Generate

func (g *Generator) Generate() error

Generate generates the static HTML site.

func (*Generator) ProcessRecords

func (g *Generator) ProcessRecords(records []ir.IRRecord)

ProcessRecords processes IR records for site generation.

type Options

type Options struct {
	Title   string
	BaseURL string
}

Options configures the site generator.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns the default site generation options.

type RequestView

type RequestView struct {
	ID              string
	Method          string
	Path            string // Original path (not template)
	PathTemplate    string
	PathParams      map[string]string
	QueryParams     map[string]any
	RequestHeaders  map[string]string
	RequestBody     any
	ResponseHeaders map[string]string
	ResponseBody    any
	StatusCode      int
	ContentType     string
	DurationMs      float64
	DedupKey        string
}

RequestView represents a single request for display.

type SiteData

type SiteData struct {
	Title       string
	GeneratedAt time.Time
	Endpoints   []*EndpointPage
	Stats       *SiteStats
}

SiteData is the top-level data for template rendering.

type SiteStats

type SiteStats struct {
	TotalRequests  int
	TotalEndpoints int
	UniqueHosts    []string
}

SiteStats contains aggregate statistics for the site.

type StatusGroup

type StatusGroup struct {
	StatusCode int
	Distinct   []*RequestView // All unique requests
	Deduped    *DedupedView   // Collapsed view with all seen values
}

StatusGroup groups requests by HTTP status code.

type StoredRecord

type StoredRecord struct {
	Record       *ir.IRRecord
	PathTemplate string
	PathParams   map[string]string
	EndpointKey  string
	DedupKey     string
}

StoredRecord holds an IR record with its computed metadata.

Jump to

Keyboard shortcuts

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