Documentation
¶
Index ¶
- Constants
- 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 IsFromCache(res *http.Response) bool
- 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 Resolve[T any]() (T, error)
- func ResolveNamed[T any](name string) (value T, err error)
- func SetFormatter(formatHandler FormatHandler)
- func ZeroOr[T comparable](value, defaultValue T) T
- type Action
- type And
- type Cache
- type Cookie
- type Fetch
- type FormatHandler
- 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 ¶
const XFromCache = "X-From-Cache"
XFromCache is the header added to responses that are returned from the cache
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 IsFromCache ¶
IsFromCache returns true if the response is from cache
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 ¶ added in v0.3.0
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 ResolveNamed ¶
ResolveNamed get the value for the name if not exist returns error
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) ([]byte, bool) Set(key string, value []byte) SetWithTimeout(key string, value []byte, timeout time.Duration) Del(key string) }
A Cache interface is used to store bytes.
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 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 |
---|---|
Package js the JavaScript implementation
|
Package js the JavaScript implementation |
modulestest
Package modulestest the module test vm
|
Package modulestest the module test vm |