preview

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package preview renders Interseptor-styled HTTP request/response PNG previews for findings evidence and report screenshots (pure Go, no cgo).

Index

Constants

View Source
const MaxPNGBytes = 5 << 20

MaxPNGBytes is the hard cap for generated PNGs (matches store image upload limit).

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a *bool for Options.Pretty literals.

func ParseBool

func ParseBool(s string, def bool) bool

ParseBool parses common truthy/falsy query/body values; empty uses def.

func Render

func Render(req, res []byte, opts Options) ([]byte, error)

Render draws an Interseptor-branded HTTP viewer PNG from raw req/res bytes.

Types

type Layout

type Layout string

Layout selects stacked (vertical) or side-by-side (horizontal) panes.

const (
	LayoutVertical   Layout = "vertical"
	LayoutHorizontal Layout = "horizontal"
)

func NormalizeLayout

func NormalizeLayout(s string) Layout

NormalizeLayout maps user input; unknown/empty → LayoutHorizontal.

type Options

type Options struct {
	Side     Side
	Layout   Layout // horizontal (default) | vertical
	Theme    Theme  // light (default) | dark
	Pretty   *bool  // indent JSON/XML bodies; nil defaults to true
	Title    string // subtitle under the product chrome (method host path → status)
	MaxLines int    // lines per pane before truncation (default 80)
	MaxCols  int    // characters per line before wrap/cut (default 100)
}

Options controls layout and truncation for Render.

type Side

type Side string

Side selects which HTTP message(s) to include in the preview.

const (
	SideBoth Side = "both"
	SideReq  Side = "req"
	SideRes  Side = "res"
)

func NormalizeSide

func NormalizeSide(s string) Side

NormalizeSide maps user input to a Side; unknown/empty → SideBoth.

type Theme

type Theme string

Theme selects color palette.

const (
	ThemeDark  Theme = "dark"
	ThemeLight Theme = "light"
)

func NormalizeTheme

func NormalizeTheme(s string) Theme

NormalizeTheme maps user input; unknown/empty → ThemeLight.

Jump to

Keyboard shortcuts

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