28 lines
903 B
Go
28 lines
903 B
Go
package rules
|
|
|
|
import (
|
|
"context"
|
|
)
|
|
|
|
// Rule interface that all rule types must implement
|
|
type Rule interface {
|
|
// Matches evaluates the rule against URL metadata and returns archivers if matched
|
|
// Returns (archivers, nil) if matched, (nil, nil) if not matched, (nil, error) on error
|
|
Matches(ctx context.Context, metadata *URLMetadata) ([]ArchiverConfig, error)
|
|
|
|
// IsValid validates that the rule is properly defined
|
|
// Returns nil if valid, error if invalid
|
|
IsValid() error
|
|
}
|
|
|
|
// RuleConfig contains the full rules configuration
|
|
type RuleConfig struct {
|
|
Rules []Rule `json:"rules"`
|
|
DefaultArchivers []ArchiverConfig `json:"default_extractors,omitempty"` // JSON tag kept for backward compatibility
|
|
}
|
|
|
|
// ArchiverConfig specifies which archiver(s) to use
|
|
type ArchiverConfig struct {
|
|
Key string `json:"key"`
|
|
Config map[string]any `json:"config,omitempty"`
|
|
}
|