client

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CurseforgeBaseURL default API base path
	CurseforgeBaseURL = "https://api.curseforge.com"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ApiQueryOption

type ApiQueryOption func(ApiQueryParams)

func PageIndex

func PageIndex(index int64) ApiQueryOption

func PageSize

func PageSize(size int64) ApiQueryOption

type ApiQueryParams

type ApiQueryParams map[string]any

func (ApiQueryParams) QueryString

func (f ApiQueryParams) QueryString() string

type CfgFunc

type CfgFunc func(config *Config)

CfgFunc is configuration function

func EnableDebug

func EnableDebug(enabled bool) CfgFunc

EnableDebug to define the API endpoint to be used

func WithEndpoint

func WithEndpoint(endpoint string) CfgFunc

WithEndpoint to define the API endpoint to be used

func WithLogger

func WithLogger(log Logger) CfgFunc

WithLogger defines the logger to be used

func WithTimeout

func WithTimeout(timeout time.Duration) CfgFunc

WithTimeout to define the API client timeout to be used

type Config

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

Config is the client config data

func NewConfig

func NewConfig(apiKey string, cfgs ...CfgFunc) *Config

NewConfig creates a new client Config with default values

func NewDefaultConfig

func NewDefaultConfig(apiKey string) *Config

NewDefaultConfig creates a new client Config with default values

func (*Config) IsDebug

func (cfg *Config) IsDebug() bool

IsDebug is debug enabled

func (*Config) NewGetRequest

func (cfg *Config) NewGetRequest(path string) (*http.Request, error)

NewGetRequest creates a new GET request object to be used with client

func (*Config) NewHTTPClient

func (cfg *Config) NewHTTPClient() *http.Client

NewHTTPClient creates a new HTTP client

func (*Config) NewPostRequest

func (cfg *Config) NewPostRequest(path string, body any) (*http.Request, error)

NewPostRequest creates a new POST request object to be used with client

type CurseClient

type CurseClient interface {
	GetGameVersions(ctx context.Context, gameID string) (versions *types.GameVersionsResponse, err error)
	GetCategories(ctx context.Context, gameID string) (*types.GetCategoriesResponse, error)
	GetMods(ctx context.Context, opts ...ModsQueryOption) (*types.ModsResponse, error)
	GetModsByIDs(ctx context.Context, req *GetModsByIdsListRequest, opts ...ModsQueryOption) (*types.ModsResponse, error)
	GetModDescription(ctx context.Context, modID int64) (*types.StringResponse, error)
	GetModFiles(ctx context.Context, modID int64) (*types.GetModFilesResponse, error)
}

func NewCurseClient

func NewCurseClient(apiKey string, opts ...CfgFunc) CurseClient

NewCurseClient creates a new Curseforge client

type DefaultSlogClientLogger

type DefaultSlogClientLogger struct {
	Logger
	// contains filtered or unexported fields
}

func (DefaultSlogClientLogger) DebugRequest

func (l DefaultSlogClientLogger) DebugRequest(res *http.Response)

func (DefaultSlogClientLogger) Printf

func (l DefaultSlogClientLogger) Printf(format string, args ...any)

func (DefaultSlogClientLogger) Println

func (l DefaultSlogClientLogger) Println(v ...any)

type GetModsByIdsListRequest

type GetModsByIdsListRequest struct {
	ModIds       []int64 `json:"modIds"`
	FilterPcOnly bool    `json:"filterPcOnly"`
}

type Logger

type Logger interface {
	Printf(format string, v ...any)
	Println(v ...any)
	DebugRequest(res *http.Response)
}

Logger is a logger definition to be used with client

func NewDefaultSlogClientLogger

func NewDefaultSlogClientLogger(logger *slog.Logger) Logger

NewDefaultSlogClientLogger creates a default logger using log/slog

type MinecraftModLoadersQueryOption

type MinecraftModLoadersQueryOption ApiQueryOption

MinecraftModLoadersQueryOption defines a ModLoader list query options

func WithIncludeAll

func WithIncludeAll(b bool) MinecraftModLoadersQueryOption

WithIncludeAll defines return a complete list or not

func WithMinecraftVersion

func WithMinecraftVersion(version string) MinecraftModLoadersQueryOption

WithMinecraftVersion defines Minecraft for ModLoader search

type MinecraftVersionsQueryOption

type MinecraftVersionsQueryOption ApiQueryOption

MinecraftVersionsQueryOption defines a ModLoader list query options

func WithSortDescending

func WithSortDescending(descending bool) MinecraftVersionsQueryOption

WithSortDescending defines sort order to be descending

type ModsQueryOption

type ModsQueryOption ApiQueryOption

func WithGameID

func WithGameID(g string) ModsQueryOption

WithGameID defines game ID for mod search

func WithModsCategoryID

func WithModsCategoryID(cid string) ModsQueryOption

WithModsCategoryID defines a category ID

func WithModsCategoryIDs

func WithModsCategoryIDs(cids string) ModsQueryOption

WithModsCategoryIDs defines a list of category IDs

func WithModsClassID

func WithModsClassID(cid string) ModsQueryOption

WithModsClassID defines mod class ID

func WithModsGameID

func WithModsGameID(id string) ModsQueryOption

WithModsGameID defines game ID to be used

func WithModsGameVersion

func WithModsGameVersion(gv string) ModsQueryOption

WithModsGameVersion defines game version to be used

func WithModsIndex

func WithModsIndex(index int64) ModsQueryOption

WithModsIndex defines result start index

func WithModsModLoaderType

func WithModsModLoaderType(mlt int) ModsQueryOption

WithModsModLoaderType defines mod loader to be used

func WithModsPageSize

func WithModsPageSize(pageSize int64) ModsQueryOption

WithModsPageSize defines result page size

func WithModsSeatchFilter

func WithModsSeatchFilter(q string) ModsQueryOption

WithModsSeatchFilter defines query filter search

func WithModsSortField

func WithModsSortField(field int) ModsQueryOption

WithModsSortField defines sort field

func WithModsSortOrder

func WithModsSortOrder(order string) ModsQueryOption

WithModsSortOrder defines sort order

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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