Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = luahttp.ErrNotFound ErrRateLimited = luahttp.ErrRateLimited )
Errors to check with errors.Is (the same values as libmangal.ErrNotFound/ErrRateLimited), from what the scripts' requests answered (see the http lib's response:check()).
var ErrClosed = errors.New("provider closed")
ErrClosed is returned by the calls to a closed provider.
Functions ¶
func LuaDoc ¶
func LuaDoc() string
LuaDoc will generate library documentation so that language servers can benefit from it.
It's optimized for the https://github.com/LuaLS/lua-language-server
func LuaTemplate ¶
func LuaTemplate() string
LuaTemplate will generate template for the valid lua script used by this provider.
func NewLoader ¶
func NewLoader(script []byte, info lm.ProviderInfo, options Options) (lm.ProviderLoader, error)
NewLoader creates new lua provider loader for the given script.
It won't run the script itself.
Types ¶
type FilterOptions ¶ added in v0.15.0
FilterOptions are the same as mangoprovider's.
func DefaultFilterOptions ¶ added in v0.15.0
func DefaultFilterOptions() FilterOptions
type HTTPError ¶ added in v0.15.8
HTTPError is a request that answered an error status other than 429, see the http lib.
type Options ¶
type Options struct {
// HTTPClient HTTP client to use for all requests. It's used as is: keeping a script's
// requests off private addresses is the app's job (mangal guards it). Headless browsers
// don't go through it.
HTTPClient *http.Client
// UserAgent to use for all HTTP requests.
UserAgent string
// CacheStore returns a gokv.Store implementation for use as a cache storage.
CacheStore func(dbName, bucketName string) (gokv.Store, error)
// PackagePaths is a list of optional extra package paths.
PackagePaths []string
// Filter options, scripts read them from sdk.options.
Filter FilterOptions
// RateLimits of the provider's requests (e.g. from its manifest), on top of the ones the
// script sets with sdk.http.rate_limit. Page images are limited too.
RateLimits []luahttp.RateLimit
// FlareSolverr makes the transport scripts' request:flaresolverr() goes through, e.g.
// mangoprovider's flaresolverr.NewTransportClient(url, client). Called once per provider
// load, on the first such request; a transport that is an io.Closer (its session) is
// closed with the provider. Nil: FlareSolverr isn't configured, those requests raise.
FlareSolverr func() http.RoundTripper
// Settings: Optional, the user's values of the provider's declared settings
// (libmangal.ProviderInfo.Settings), asked when it loads; scripts read them with
// sdk.settings.get. Nil: every setting has its default.
Settings lm.SettingsFunc
// Debug logs what doesn't go through HTTPClient: cache hits, FlareSolverr requests and
// headless page loads, in netutil.LoggingTransport's format. Nothing if nil.
Debug func(format string, a ...any)
}
Options are the general luaprovider options.
func DefaultOptions ¶
func DefaultOptions() Options
type RateLimitError ¶ added in v0.18.0
type RateLimitError = luahttp.RateLimitError
RateLimitError is a request that answered 429.