mirror of
https://github.com/navidrome/navidrome.git
synced 2026-02-02 06:24:14 +00:00
- Updated the host function signatures in `nd_host_artwork.go`, `nd_host_scheduler.go`, `nd_host_subsonicapi.go`, and `nd_host_websocket.go` to accept a single parameter for JSON requests. - Introduced structured request and response types for various cache operations in `nd_host_cache.go`. - Modified cache functions to marshal requests to JSON and unmarshal responses, improving error handling and code clarity. - Removed redundant memory allocation for string parameters in favor of JSON marshaling. - Enhanced error handling in WebSocket and cache operations to return structured error responses.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
// Code generated by hostgen. DO NOT EDIT.
|
|
//
|
|
// This file contains client wrappers for the Ping host service.
|
|
// It is intended for use in Navidrome plugins built with TinyGo.
|
|
//
|
|
//go:build wasip1
|
|
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"github.com/extism/go-pdk"
|
|
)
|
|
|
|
// ping_ping is the host function provided by Navidrome.
|
|
//
|
|
//go:wasmimport extism:host/user ping_ping
|
|
func ping_ping(uint64) uint64
|
|
|
|
// PingPingResponse is the response type for Ping.Ping.
|
|
type PingPingResponse struct {
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
// PingPing calls the ping_ping host function.
|
|
func PingPing() (*PingPingResponse, error) {
|
|
// No parameters - allocate empty JSON object
|
|
reqMem := pdk.AllocateBytes([]byte("{}"))
|
|
defer reqMem.Free()
|
|
|
|
// Call the host function
|
|
responsePtr := ping_ping(reqMem.Offset())
|
|
|
|
// Read the response from memory
|
|
responseMem := pdk.FindMemory(responsePtr)
|
|
responseBytes := responseMem.ReadBytes()
|
|
|
|
// Parse the response
|
|
var response PingPingResponse
|
|
if err := json.Unmarshal(responseBytes, &response); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &response, nil
|
|
}
|