MCPcopy Index your code
hub / github.com/WendellCraft/ModpackDebuggerKit / getModInfo

Function getModInfo

modrinth.go:28–45  ·  view source on GitHub ↗
(sha1Hash string)

Source from the content-addressed store, hash-verified

26}
27
28func getModInfo(sha1Hash string) (*ModrinthVersion, error) {
29 url := fmt.Sprintf("%s/version_file/%s", modrinthAPIBase, sha1Hash)
30 resp, err := http.Get(url)
31 if err != nil {
32 return nil, fmt.Errorf("error fetching mod info for hash %s: %w", sha1Hash, err)
33 }
34 defer resp.Body.Close()
35
36 if resp.StatusCode != http.StatusOK {
37 return nil, fmt.Errorf("API returned status %d for hash %s", resp.StatusCode, sha1Hash)
38 }
39
40 var info ModrinthVersion
41 if err := json.NewDecoder(resp.Body).Decode(&info); err != nil {
42 return nil, fmt.Errorf("error decoding response for hash %s: %w", sha1Hash, err)
43 }
44 return &info, nil
45}
46
47func getProjectVersions(projectID string) ([]ModrinthVersion, error) {
48 url := fmt.Sprintf("%s/project/%s/version", modrinthAPIBase, projectID)

Callers 1

modrinthSyncMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected