simplecdxj

package module
v0.0.0-...-c3aca5c Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: MIT Imports: 8 Imported by: 6

Documentation

Index

Constants

View Source
const (
	HEADER_PREFIX = "!"
)

Variables

View Source
var RecordTypeStrings = []string{
	"response",
	"request",
	"revisit",
}

Functions

func Index

func Index(r io.Reader) (io.Reader, error)

Index indexes (sorts) the CDXJ read from reader

Types

type CDXJ

type CDXJ struct {
	Header  Header
	Records []*Record
}

CDXJ represents a CDXJ formatted file

func (*CDXJ) Format

func (cdxj *CDXJ) Format() string

Format returns the CDXJ as formatted string

type Header map[string][]byte

Header maps the CDXJ field-name and field-value

func (Header) Delete

func (h Header) Delete(key string)

Delete removes the field-name

func (Header) Format

func (h Header) Format() string

Format returns the Header as a formatted string

func (Header) Get

func (h Header) Get(key string) []byte

Get returns the field-value for a given field-name

func (Header) Has

func (h Header) Has(key string) bool

Has retuns true if the key exists

func (Header) Set

func (h Header) Set(key string, val []byte)

Set sets the field-value for a given field-name

type Reader

type Reader interface {
	// Read reads in, parses, and returns the CDXJ
	Read() (*CDXJ, error)

	// ReadLine returns the next line of CDXJ
	ReadLine() (string, error)
}

Reader is an interface to a CDXJ reader

func NewReader

func NewReader(r io.Reader) (Reader, error)

NewReader wraps the given reader and returns a new CDXJ reader

type Record

type Record struct {
	SURT      string     // SURT formatted domain name
	Timestamp time.Time  // Record timestamp
	Type      RecordType // Record type
	Content   []byte     // Record contents
}

Record represents an CDXJ record

func (*Record) Format

func (r *Record) Format() string

Format returns the string representation of the record

type RecordType

type RecordType int

RecordType represents the type of CDXJ record

const (
	ResponseRecordType RecordType = iota + 1
	RequestRecordType
	RevisitRecordType
)

func ParseRecordType

func ParseRecordType(v string) (RecordType, error)

ParseRecordType parses the given string value and returns its RecordType

func (RecordType) String

func (rt RecordType) String() string

String returns the string representation of the RecordType; if a string can not be found, an empty string is returned instead

type Writer

type Writer interface {
	// Write writes the CDXJ using the wrapped writer
	Write(cdxj *CDXJ) (int, error)
}

Writer is an interface for writing CDXJs

func NewWriter

func NewWriter(w io.Writer) Writer

NewWriter wraps the given writer and returns a CDXJ writer

Jump to

Keyboard shortcuts

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