validator

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthMethod

type AuthMethod string

AuthMethod 认证方式

const (
	// AuthMethodCookie Cookie 认证
	AuthMethodCookie AuthMethod = "cookie"
	// AuthMethodAPIKey API Key 认证
	AuthMethodAPIKey AuthMethod = "apikey"
)

type DynamicSiteConfig

type DynamicSiteConfig interface {
	GetName() string
	GetBaseURL() string
	GetAuthMethod() AuthMethod
	GetCookie() string
	GetAPIKey() string
	GetAPIURL() string
}

DynamicSiteConfig 动态站点配置接口

type SiteBasicInfo

type SiteBasicInfo struct {
	Name        string     `json:"name"`
	DisplayName string     `json:"display_name"`
	BaseURL     string     `json:"base_url"`
	AuthMethod  AuthMethod `json:"auth_method"`
}

SiteBasicInfo 站点基本信息

type SiteValidator

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

SiteValidator 站点验证器 用于验证新站点配置是否有效

func NewSiteValidator

func NewSiteValidator() *SiteValidator

NewSiteValidator 创建站点验证器

func NewSiteValidatorWithOptions

func NewSiteValidatorWithOptions(opts ...ValidatorOption) *SiteValidator

NewSiteValidatorWithOptions 创建带选项的验证器

func (*SiteValidator) Validate

Validate 验证站点配置

func (*SiteValidator) ValidateConfig

func (v *SiteValidator) ValidateConfig(config DynamicSiteConfig) []ValidationError

ValidateConfig 验证DynamicSiteConfig

type TorrentPreview

type TorrentPreview struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

TorrentPreview 种子预览信息

type ValidationError

type ValidationError struct {
	Field   string `json:"field"`
	Message string `json:"message"`
}

ValidationError 验证错误

type ValidationRequest

type ValidationRequest struct {
	Name        string     `json:"name"`
	DisplayName string     `json:"display_name"`
	BaseURL     string     `json:"base_url"`
	AuthMethod  AuthMethod `json:"auth_method"`
	Cookie      string     `json:"cookie,omitempty"`
	APIKey      string     `json:"api_key,omitempty"`
	APIURL      string     `json:"api_url,omitempty"`
	RSSURL      string     `json:"rss_url,omitempty"` // 用于验证的RSS URL
}

ValidationRequest 验证请求

type ValidationResult

type ValidationResult struct {
	Success       bool              `json:"success"`
	Message       string            `json:"message"`
	Errors        []ValidationError `json:"errors,omitempty"`
	FreeTorrents  []TorrentPreview  `json:"free_torrents,omitempty"`
	TotalTorrents int               `json:"total_torrents"`
	SiteInfo      *SiteBasicInfo    `json:"site_info,omitempty"`
	ResponseTime  time.Duration     `json:"response_time"`
}

ValidationResult 验证结果

type ValidatorOption

type ValidatorOption func(*SiteValidator)

ValidatorOption 验证器选项

func WithHTTPClient

func WithHTTPClient(client *http.Client) ValidatorOption

WithHTTPClient 设置HTTP客户端

func WithTimeout

func WithTimeout(d time.Duration) ValidatorOption

WithTimeout 设置超时时间

Jump to

Keyboard shortcuts

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