Documentation
¶
Index ¶
- func DatapackIndexerNames() []string
- func DatapackIndexerOrigin(idx DatapackIndexer) string
- func FirstDatapackLatestFile(ctx context.Context, datapackID, gameVersion string, idxs []DatapackIndexer) (*DatapackFile, DatapackIndexer, error)
- func IsAuthError(err error) bool
- func IsNetworkError(err error) bool
- func IsNotFound(err error) bool
- func IsRateLimit(err error) bool
- func RegisterDatapackIndexer(name string, factory DatapackIndexerFactory)
- func RegisterIndexer(name string, factory IndexerFactory)
- type Datapack
- type DatapackFile
- type DatapackIndexer
- type DatapackIndexerFactory
- type DatapackSearchResult
- type ErrorKind
- type HTTPClient
- type IndexerError
- func NewAPIError(indexer string, statusCode int, url string, body string) *IndexerError
- func NewAuthConfigError(indexer string, msg string) *IndexerError
- func NewDecodeError(indexer string, url string, err error) *IndexerError
- func NewNetworkError(indexer string, url string, err error) *IndexerError
- type IndexerFactory
- type Modpack
- type ModpackFile
- type ModpackIndexer
- type OriginReporter
- type SearchResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DatapackIndexerNames ¶ added in v1.0.39
func DatapackIndexerNames() []string
DatapackIndexerNames returns the registered datapack indexer names, sorted, so callers can search every provider for merged coverage.
func DatapackIndexerOrigin ¶ added in v1.0.39
func DatapackIndexerOrigin(idx DatapackIndexer) string
DatapackIndexerOrigin returns the indexer's configured API origin, or "" when the indexer does not report one.
func FirstDatapackLatestFile ¶ added in v1.0.39
func FirstDatapackLatestFile(ctx context.Context, datapackID, gameVersion string, idxs []DatapackIndexer) (*DatapackFile, DatapackIndexer, error)
FirstDatapackLatestFile resolves a datapack file against the given indexers in order and returns the first success with the indexer that resolved it (for download trust scoping). An id from one provider must not be resolvable on another, so cross-provider misses are expected and joined into the final error.
func IsNetworkError ¶
Reports whether the error is a network error
func RegisterDatapackIndexer ¶ added in v1.0.39
func RegisterDatapackIndexer(name string, factory DatapackIndexerFactory)
RegisterDatapackIndexer registers a DatapackIndexerFactory under the given name. Typically called from an indexer package's init() function.
func RegisterIndexer ¶
func RegisterIndexer(name string, factory IndexerFactory)
RegisterIndexer registers an IndexerFactory under the given name. Typically called from an indexer package's init() function.
Types ¶
type Datapack ¶ added in v1.0.39
type Datapack struct {
ID string `json:"id"`
IndexerID string `json:"indexer_id"`
Indexer string `json:"indexer"`
Name string `json:"name"`
Slug string `json:"slug"`
Summary string `json:"summary"`
IconURL string `json:"icon_url"`
WebsiteURL string `json:"website_url"`
Author string `json:"author"`
DownloadCount int64 `json:"download_count"`
GameVersions []string `json:"game_versions"`
DateModified string `json:"date_modified"`
}
Datapack is a datapack as reported by an indexer.
type DatapackFile ¶ added in v1.0.39
type DatapackFile struct {
DatapackID string `json:"datapack_id"`
Filename string `json:"filename"`
DownloadURL string `json:"download_url"`
Size int64 `json:"size"`
SHA1 string `json:"sha1"`
SHA512 string `json:"sha512"`
GameVersions []string `json:"game_versions"`
}
DatapackFile is a downloadable datapack artifact.
type DatapackIndexer ¶ added in v1.0.39
type DatapackIndexer interface {
// SearchDatapacks searches for datapacks matching the criteria.
SearchDatapacks(ctx context.Context, query string, gameVersion string, offset, limit int) (*DatapackSearchResult, error)
// GetDatapackLatestFile returns the primary downloadable file for a
// datapack, optionally filtered to a game version.
GetDatapackLatestFile(ctx context.Context, datapackID string, gameVersion string) (*DatapackFile, error)
// GetIndexerName returns the name of this indexer (e.g. "modrinth").
GetIndexerName() string
}
DatapackIndexer defines the interface for datapack discovery services. A datapack is a self-contained world-data bundle (recipes, loot tables, worldgen) that runs on Vanilla servers without a mod loader, so it is a separate content type from mods and modpacks.
func DatapackIndexersFor ¶ added in v1.0.39
func DatapackIndexersFor(name, apiKey string, cfg *config.Config) ([]DatapackIndexer, error)
DatapackIndexersFor builds the datapack indexer set for file resolution: the named indexer, or every registered provider when name is empty so search results from any provider remain installable.
func NewDatapackIndexer ¶ added in v1.0.39
NewDatapackIndexer creates a DatapackIndexer by name using the factory registry.
type DatapackIndexerFactory ¶ added in v1.0.39
type DatapackIndexerFactory func(apiKey string, cfg *config.Config) DatapackIndexer
DatapackIndexerFactory creates a DatapackIndexer from an API key and config.
type DatapackSearchResult ¶ added in v1.0.39
DatapackSearchResult holds a page of datapack search results.
type HTTPClient ¶
type HTTPClient struct {
// contains filtered or unexported fields
}
HTTPClient wraps http.Client with common indexer request logic.
func NewHTTPClient ¶
func NewHTTPClient(indexer string, userAgent string, extraHeaders map[string]string) *HTTPClient
NewHTTPClient creates a shared HTTP client for an indexer.
type IndexerError ¶
type IndexerError struct {
Kind ErrorKind
Indexer string
StatusCode int
URL string
Body string
Err error
}
func NewAPIError ¶
func NewAPIError(indexer string, statusCode int, url string, body string) *IndexerError
It automatically classifies 401/403 as Auth, 404 as NotFound, 429 as RateLimit.
func NewAuthConfigError ¶
func NewAuthConfigError(indexer string, msg string) *IndexerError
Missing API key configuration
func NewDecodeError ¶
func NewDecodeError(indexer string, url string, err error) *IndexerError
JSON decode failures.
func NewNetworkError ¶
func NewNetworkError(indexer string, url string, err error) *IndexerError
IndexerError for network-level failures like dns
func (*IndexerError) Error ¶
func (e *IndexerError) Error() string
func (*IndexerError) Unwrap ¶
func (e *IndexerError) Unwrap() error
type IndexerFactory ¶
type IndexerFactory func(apiKey string, cfg *config.Config) ModpackIndexer
IndexerFactory creates a ModpackIndexer from an API key and config.
type Modpack ¶
type Modpack struct {
ID string `json:"id"`
IndexerID string `json:"indexer_id"` // Original ID from the indexer
Indexer string `json:"indexer"` // Which indexer this came from
Name string `json:"name"`
Slug string `json:"slug"`
Summary string `json:"summary"`
Description string `json:"description"`
LogoURL string `json:"logo_url"`
WebsiteURL string `json:"website_url"`
DownloadCount int64 `json:"download_count"`
Categories []string `json:"categories"`
GameVersions []string `json:"game_versions"`
ModLoaders []string `json:"mod_loaders"`
LatestFileID string `json:"latest_file_id"`
DateCreated time.Time `json:"date_created"`
DateModified time.Time `json:"date_modified"`
DateReleased time.Time `json:"date_released"`
}
Modpack represents a modpack from any indexer
type ModpackFile ¶
type ModpackFile struct {
ID string `json:"id"`
ModpackID string `json:"modpack_id"`
DisplayName string `json:"display_name"`
FileName string `json:"file_name"`
FileDate time.Time `json:"file_date"`
FileLength int64 `json:"file_length"`
ReleaseType string `json:"release_type"` // "release", "beta", "alpha"
DownloadURL string `json:"download_url"`
GameVersions []string `json:"game_versions"`
ModLoader string `json:"mod_loader"`
ServerPackFileID *string `json:"server_pack_file_id,omitempty"`
SortIndex int `json:"sort_index"`
VersionNumber string `json:"version_number"` // Human-readable version for Modrinth
}
ModpackFile represents a downloadable file for a modpack
type ModpackIndexer ¶
type ModpackIndexer interface {
// SearchModpacks searches for modpacks with the given criteria
SearchModpacks(ctx context.Context, query string, gameVersion string, modLoader string, offset, limit int) (*SearchResult, error)
// GetModpack retrieves detailed information about a specific modpack
GetModpack(ctx context.Context, modpackID string) (*Modpack, error)
// GetModpackFiles retrieves all available files for a modpack
GetModpackFiles(ctx context.Context, modpackID string) ([]ModpackFile, error)
// GetIndexerName returns the name of this indexer (e.g., "fuego", "modrinth")
GetIndexerName() string
}
ModpackIndexer defines the interface for modpack indexing services
func NewIndexer ¶
NewIndexer creates a ModpackIndexer by name using the factory registry.
type OriginReporter ¶ added in v1.0.39
type OriginReporter interface {
Origin() string
}
OriginReporter is an optional DatapackIndexer capability: it reports the configured API origin. Downloads inherit this origin's network trust (see minecraft.DownloadAllowsPrivate), so a public index can never point the panel at internal hosts while self-hosted indexes keep serving LAN files. Indexers that do not report an origin get strict public-only downloads.