1.9 KiB
1.9 KiB
WebDesk 3rd party App Market client API for Go
This allows you to make custom (known as 3rd party) App Market server clients for your intended purpose.
Features
- Listing currently uploaded apps
- Uploading new apps
- Editing app info
- Delete apps
Prerequisites
- Go (1.23.1 or later, older will work with go.mod changes to the version)
Usage
Import in your Go code:
import (
"git.fluffy.pw/matu6968/webdesk-appmarket-golang"
)
Configuration
In the .env file this is the only thing you can set
AUTH_TOKEN=bearer-token-here # Put your token generated from the server .env file
API usage
- List uploaded apps:
// Create new client
c := client.NewClient("http://localhost:8080", os.Getenv("AUTH_TOKEN"))
// List all apps
apps, err := c.GetApps()
if err != nil {
log.Fatal("Failed to get apps:", err)
}
fmt.Printf("Found %d apps\n", len(apps))
- Upload an app:
// Upload new app
metadata := client.AppMetadata{
Name: "Camera",
Ver: "6",
Info: "This is a camera app",
Pub: "matu6968",
}
newApp, err := c.UploadApp(metadata, "./index.js")
if err != nil {
log.Fatal("Failed to upload app:", err)
}
fmt.Printf("Uploaded app with ID: %s\n", newApp.AppID)
- Edit an app:
// Edit app
metadata := client.AppMetadata{ // only specify what you need
Name: "Camera",
Ver: "7",
Info: "This is a new camera app",
Pub: "matu6968",
}
err = c.EditApp(newApp.AppID, metadata, "./index.js") // replace newApp.AppID with the app id you want to delete
if err != nil {
log.Fatal("Failed to edit app:", err)
}
fmt.Println("App updated successfully")
- Delete an app:
// Delete app
err = c.DeleteApp(newApp.AppID) // replace newApp.AppID with the app id you want to delete
if err != nil {
log.Fatal("Failed to delete app:", err)
}
fmt.Println("App deleted successfully")