Documentation
¶
Index ¶
- Variables
- func Analyze(ctx *plugin.Context, s *Schema, content string) any
- func CookieToString(cookies []*http.Cookie) []string
- func EmptyOr[T any](value, defaultValue []T) []T
- func GetElement(act Action, ctx *plugin.Context, content any) (string, error)
- func GetElements(act Action, ctx *plugin.Context, content any) ([]string, error)
- func GetString(act Action, ctx *plugin.Context, content any) (string, error)
- func GetStrings(act Action, ctx *plugin.Context, content any) ([]string, error)
- func MustResolve[T any]() T
- func MustResolveNamed[T any](name string) T
- func Override[T any](value T) bool
- func OverrideLazy[T any](initFunc func() (T, error)) bool
- func OverrideNamed(name string, value any) (ok bool)
- func ParseCookie(cookies string) []*http.Cookie
- func ParseSetCookie(cookies ...string) []*http.Cookie
- func Provide[T any](value T) bool
- func ProvideLazy[T any](initFunc func() (T, error)) bool
- func ProvideNamed(name string, value any) (ok bool)
- func ProxyFromRequest(req *http.Request) (*url.URL, error)
- func Resolve[T any]() (T, error)
- func ResolveNamed[T any](name string) (value T, err error)
- func SetFormatter(formatHandler FormatHandler)
- func WithProxyURL(ctx context.Context, proxy *url.URL) context.Context
- func ZeroOr[T comparable](value, defaultValue T) T
- type Action
- type And
- type Cache
- type CacheOptions
- type Cookie
- type Fetch
- type FormatHandler
- type Not
- type Operator
- type Or
- type Property
- type Schema
- func (schema *Schema) AddProperty(field string, s Schema) *Schema
- func (schema *Schema) CloneWithType(typ Type) *Schema
- func (schema Schema) MarshalText() ([]byte, error)
- func (schema Schema) MarshalYAML() (any, error)
- func (schema *Schema) SetInit(action Action) *Schema
- func (schema *Schema) SetProperty(m Property) *Schema
- func (schema *Schema) SetRule(action Action) *Schema
- func (schema *Schema) UnmarshalText(text []byte) error
- func (schema *Schema) UnmarshalYAML(node *yaml.Node) (err error)
- type Step
- type Steps
- type Type
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidSchema invalid schema error ErrInvalidSchema = errors.New("invalid schema") // ErrAliasRecursive invalid alias error ErrAliasRecursive = errors.New("alias can't be recursive") // ErrInvalidAction invalid action error ErrInvalidAction = errors.New("invalid action") // ErrInvalidStep invalid step error ErrInvalidStep = errors.New("invalid step") )
Functions ¶
func CookieToString ¶
CookieToString returns the slice string of the slice http.Cookie.
func EmptyOr ¶
func EmptyOr[T any](value, defaultValue []T) []T
EmptyOr if slice is empty returns the defaultValue
func GetElement ¶
GetElement run the action returns an element string
func GetElements ¶
GetElements run the action returns a slice of element string
func GetStrings ¶
GetStrings run the action returns a slice of string
func MustResolveNamed ¶
MustResolveNamed get the value for the name, if not exist create panic
func OverrideLazy ¶
OverrideLazy save the value for the name and return is it override
func OverrideNamed ¶
OverrideNamed save the value for the name and return is it override
func ParseCookie ¶
ParseCookie parses the cookie string and return a slice http.Cookie.
func ParseSetCookie ¶
ParseSetCookie parses the set-cookie strings and return a slice http.Cookie.
func ProvideLazy ¶
ProvideLazy save the lazy init value and return is it saved
func ProvideNamed ¶
ProvideNamed save the value for the name and return is it saved
func ProxyFromRequest ¶
ProxyFromRequest returns a proxy URL on request context.
func ResolveNamed ¶
ResolveNamed get the value for the name if not exist returns error
func WithProxyURL ¶
WithProxyURL returns a copy of parent context in which the proxy associated with context.
func ZeroOr ¶
func ZeroOr[T comparable](value, defaultValue T) T
ZeroOr if value is zero value returns the defaultValue
Types ¶
type Action ¶
type Action interface { // Left returns the left Action Left() Action // Right returns the right Action Right() Action }
Action The Schema Action
type And ¶
type And struct {
// contains filtered or unexported fields
}
And Action node of Operator and
func (And) MarshalYAML ¶
type Cache ¶
type Cache interface { Get(key string, opts ...CacheOptions) ([]byte, bool) Set(key string, value []byte, opts ...CacheOptions) Del(key string, opts ...CacheOptions) }
A Cache interface is used to store bytes.
type CacheOptions ¶
type Cookie ¶
type Cookie interface { http.CookieJar // CookieString returns the cookies string for the given URL. CookieString(u *url.URL) []string // DeleteCookie delete the cookies for the given URL. DeleteCookie(u *url.URL) }
Cookie manages storage and use of cookies in HTTP requests. Implementations of Cookie must be safe for concurrent use by multiple goroutines.
type Fetch ¶
type Fetch interface { // Do sends an HTTP request and returns an HTTP response, following // policy (such as redirects, cookies, auth) as configured on the // client. Do(*http.Request) (*http.Response, error) }
Fetch http client interface
type FormatHandler ¶
type FormatHandler interface { // Format the data to the given Type Format(data any, format Type) (any, error) }
FormatHandler schema property formatter
type Not ¶
type Not struct {
// contains filtered or unexported fields
}
Not Action node of Operator not
func (Not) MarshalYAML ¶
type Operator ¶
type Operator string
Operator The Action operator.
const ( // OperatorAnd The Operator of and. // Action result A, B; Join the A + B. OperatorAnd Operator = "and" // OperatorOr The Operator of or. // Action result A, B; if result A is nil return B else return A. OperatorOr Operator = "or" // OperatorNot The Operator of not. // Action result A, B; if result A is not nil return B else return nil. OperatorNot Operator = "not" )
type Or ¶
type Or struct {
// contains filtered or unexported fields
}
Or Action node of Operator or
func (Or) MarshalYAML ¶
type Schema ¶
type Schema struct { Type Type `yaml:"type"` Format Type `yaml:"format,omitempty"` Init Action `yaml:"init,omitempty"` Rule Action `yaml:"rule,omitempty"` Properties Property `yaml:"properties,omitempty"` }
Schema The schema.
func NewSchema ¶
NewSchema returns a new Schema with the given Type. The first argument is the Schema.Type, second is the Schema.Format.
func (*Schema) AddProperty ¶
AddProperty append a field string with Schema to Schema.Properties.
func (*Schema) CloneWithType ¶
CloneWithType returns a copy of Schema. Schema.Format and Schema.Rule will be copied.
func (Schema) MarshalText ¶
MarshalText encodes the receiver into UTF-8-encoded text and returns the result.
func (Schema) MarshalYAML ¶
MarshalYAML encodes the Schema
func (*Schema) SetProperty ¶
SetProperty set the Property to Schema.Properties.
func (*Schema) UnmarshalText ¶
UnmarshalText must be able to decode the form generated by MarshalText.
func (*Schema) UnmarshalYAML ¶
UnmarshalYAML decodes the Schema from yaml
type Steps ¶
type Steps []Step
Steps slice of Step
func (Steps) MarshalYAML ¶
func (*Steps) UnmarshalYAML ¶
type Type ¶
type Type string
Type The property type.
const ( // StringType The Type of string. StringType Type = "string" // NumberType The Type of number. NumberType Type = "number" // IntegerType The Type of integer. IntegerType Type = "integer" // BooleanType The Type of boolean. BooleanType Type = "boolean" // ObjectType The Type of object. ObjectType Type = "object" // ArrayType The Type of array. ArrayType Type = "array" )
Source Files
¶
Directories
¶
Path | Synopsis |
---|---|
core
module
|
|
ctl
module
|
|
fetch
module
|
|
Package js the JavaScript implementation
|
Package js the JavaScript implementation |
modules/cache
Package cache the cache JS implementation
|
Package cache the cache JS implementation |
modules/cookie
Package cookie the cookie JS implementation
|
Package cookie the cookie JS implementation |
modules/crypto
Package crypto the crypto JS implementation
|
Package crypto the crypto JS implementation |
modules/encoding
Package encoding the encoding JS implementation
|
Package encoding the encoding JS implementation |
modules/http
Package http the http JS implementation
|
Package http the http JS implementation |
modulestest
Package modulestest the module test vm
|
Package modulestest the module test vm |
jsmodules
module
|
|
gq
Package gq the goquery parser
|
Package gq the goquery parser |
js
Package js the js parser
|
Package js the js parser |
json
Package json the json parser
|
Package json the json parser |
regex
Package regex the regexp parser
|
Package regex the regexp parser |
xpath
Package xpath the xpath parser
|
Package xpath the xpath parser |
plugin
module
|
|
sample
|
|