snapshotparse

package
v0.141.3 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package snapshotparse serves deterministic extraction from saved HTML with a receipt for the exact input bytes. Owners provide the parser and auth.

Index

Constants

View Source
const (
	SchemaVersion = "snapshot.parse.v1"
	MaxBytes      = 8 << 20
	Parsed        = "parsed"
	Empty         = "empty"
	NotApplicable = "not_applicable"
)

Variables

This section is empty.

Functions

func Handler

func Handler(id, version string, parse Parser) http.Handler

Handler accepts POST with HTML or XHTML, X-Source-URL, X-Source-SHA256 and X-Capture-ID. Mount it behind the owning service's existing authorization.

Types

type Input

type Input struct {
	HTML        []byte
	URL         string
	SHA256      string
	CaptureID   string
	ContentType string
}

Input contains verified, unmodified HTML bytes and their recorded provenance. URL is for evidence and relative link resolution. The handler never fetches it.

func (Input) UTF8

func (in Input) UTF8() ([]byte, error)

UTF8 returns an HTML-decoded view for text-oriented parsers. The original bytes in HTML and the checksum in the receipt remain unchanged.

type Parser

type Parser func(context.Context, Input) (Result, error)

Parser inspects only the supplied bytes. It should honor cancellation and bound its own work. Errors are reported without disclosing parser internals.

type Result

type Result struct {
	Status     string          `json:"status"`
	Data       any             `json:"data"`
	Warnings   []string        `json:"warnings,omitempty"`
	Truncation map[string]bool `json:"truncation,omitempty"`
}

Result holds deterministic signals. Empty means the supplied page had no supported signals. Use NotApplicable when the input cannot support the check.

Jump to

Keyboard shortcuts

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