rinth

package module
v0.0.0-...-28c3a5e Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

README

rinth godocs.io builds.sr.ht status

A go library for reading or fetching mods from Modrinth.

Discussion and patches can be found here.

Documentation

Overview

rinth is a library for reading mod data from Modrinth.

Index

Constants

View Source
const BaseURL = "https://api.modrinth.com/api/v1/"

BaseURL is the default base URL for the Modrinth JSON API.

Variables

This section is empty.

Functions

func String

func String(v string) *string

String is a helper routine that allocates a new string value to store v and returns a pointer to it.

Types

type Client

type Client struct {
	HTTPClient *http.Client
	BaseURL    string
}

Client used for metservice-go.

func NewClient

func NewClient() *Client

NewClient constructs a client using http.DefaultClient and the default base URL. The returned client is ready for use.

func (*Client) Do

func (c *Client) Do(ctx context.Context, path string, v interface{}) (*http.Response, error)

Do sends an API request and returns the API responce. The API responce is JSON decoded and stored in the value pointed to by v, or returned as an error if an API error has occured. If v is nil, and no error happens, the responce is returned as is.

func (*Client) GetMod

func (c *Client) GetMod(ctx context.Context, id string) (*Mod, *http.Response, error)

GetMod gets a Mod for a given Mod ID.

type Mod

type Mod struct {
	ID          *string   `json:"id,omitempty"`          //The ID of the mod, encoded as a base62 string
	Slug        *string   `json:"slug,omitempty"`        //The slug of a mod, used for vanity URLs
	Team        *string   `json:"team,omitempty"`        //The id of the team that has ownership of this mod
	Title       *string   `json:"title,omitempty"`       //The title or name of the mod
	Description *string   `json:"description,omitempty"` //A short description of the mod
	Body        *string   `json:"body,omitempty"`        //A long form description of the mod.
	BodyUrl     *string   `json:"body_url,omitempty"`    //DEPRECATED The link to the long description of the mod (Optional)
	Published   *string   `json:"published,omitempty"`   //The date at which the mod was first published
	Updated     *string   `json:"updated,omitempty"`     //The date at which the mod was updated
	Status      *string   `json:"status,omitempty"`      //The status of the mod - approved, rejected, draft, unlisted, processing, or unknown
	ClientSide  *string   `json:"client_side,omitempty"` //The support range for the client mod - required, optional, unsupported, or unknown
	ServerSide  *string   `json:"server_side,omitempty"` //The support range for the server mod - required, optional, unsupported, or unknown
	Downloads   *int      `json:"downloads,omitempty"`   //The total number of downloads the mod has
	Categories  *[]string `json:"categories,omitempty"`  //A list of the categories that the mod is in
	Versions    *[]string `json:"versions,omitempty"`    //A list of ids for versions of the mod
	IconUrl     *string   `json:"icon_url,omitempty"`    //The URL of the icon of the mod (Optional)
	IssuesUrl   *string   `json:"issues_url,omitempty"`  //An optional link to where to submit bugs or issues with the mod (Optional)
	SourceUrl   *string   `json:"source_url,omitempty"`  //An optional link to the source code for the mod (Optional)
	WikiUrl     *string   `json:"wiki_url,omitempty"`    //An optional link to the mod's wiki page or other relevant information (Optional)
	DiscordUrl  *string   `json:"discord_url,omitempty"` //An optional link to the mod's discord (Optional)
}

Mod represents a Modrinth's mod page.

type StatusError

type StatusError struct {
	Code int
}

StatusError is returned when a bad responce code is received from the API.

func (StatusError) Error

func (e StatusError) Error() string

Jump to

Keyboard shortcuts

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