api

package
v0.2.0-beta.5 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SortClosest = "closest"
	SortReverse = "reverse"
)
View Source
const (
	MatchTypeExact  = "exact"
	MatchTypePrefix = "prefix"
	MatchTypeHost   = "host"
	MatchTypeDomain = "domain"
)
View Source
const (
	OutputCdxj = "cdxj"
	OutputJson = "json"
)

Variables

This section is empty.

Functions

func From

func From(f string) (int64, error)

From parses string f to unix time according to https://pywb.readthedocs.io/en/latest/manual/cdxserver_api.html#from-to:

func MatchType

func MatchType(ssurt string, matchType string) string

func To

func To(t string) (int64, error)

To parses string t to unix time according to https://pywb.readthedocs.io/en/latest/manual/cdxserver_api.html#from-to:

Types

type CoreAPI

type CoreAPI struct {
	Collection string
	Urls       []*url.Url
	FromTo     *DateRange
	MatchType  string
	Limit      int
	Sort       string
	Closest    string
	Output     string
	Filter     []string
	Fields     []string
}

CoreAPI implements a subset of https://pywb.readthedocs.io/en/latest/manual/cdxserver_api.html.

func ClosestAPI

func ClosestAPI(closest string, u *url.Url) *CoreAPI

func Parse

func Parse(r *http.Request) (*CoreAPI, error)

Parse parses the request r into a *CoreAPI.

func (*CoreAPI) Url

func (capi *CoreAPI) Url() *url.Url

type DateRange

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

func NewDateRange

func NewDateRange(fromstr string, tostr string) (*DateRange, error)

func (*DateRange) Contains

func (d *DateRange) Contains(ts int64) bool

func (*DateRange) ContainsStr

func (d *DateRange) ContainsStr(ts string) (bool, error)

ContainsStr returns true if the timestamp ts contained by the bounds defined by the DateRange d. input 'ts' is 'trusted' and does not have the same parsing complexity as a From or To string

func (*DateRange) ContainsTime

func (d *DateRange) ContainsTime(t time.Time) (bool, error)

ContainsTime returns true if time.Time t is contained by the bounds defined by the DateRange d.

type Filter

type Filter []filter

func ParseFilter

func ParseFilter(filterStrings []string, remap map[string]string) Filter

func (Filter) Eval

func (f Filter) Eval(c *schema.Cdx) bool

type Op

type Op int
const (
	OpContains Op = iota
	OpExact
	OpRegexp
)

type SearchAPI

type SearchAPI struct {
	*CoreAPI
	FilterMap map[string]string
}

func (SearchAPI) Closest

func (c SearchAPI) Closest() string

func (SearchAPI) DateRange

func (c SearchAPI) DateRange() index.DateRange

func (SearchAPI) Filter

func (c SearchAPI) Filter() index.Filter

func (SearchAPI) Key

func (c SearchAPI) Key() string

func (SearchAPI) Keys

func (c SearchAPI) Keys() []string

func (SearchAPI) Limit

func (c SearchAPI) Limit() int

func (SearchAPI) MatchType

func (c SearchAPI) MatchType() string

func (SearchAPI) Sort

func (c SearchAPI) Sort() index.Sort

Jump to

Keyboard shortcuts

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