ソースを参照

Scannable by hdsv2 scanner

TC pushbot 5 4 年 前
コミット
c8fa8768e9
1 ファイル変更55 行追加0 行削除
  1. 55 0
      handlers.go

+ 55 - 0
handlers.go

@@ -14,6 +14,19 @@ type Status struct {
 	Status          string //Status of the device, support {downloading, converting, playing, paused, ready}
 }
 
+type Endpoint struct {
+	Name       string
+	RelPath    string
+	Desc       string
+	Type       string
+	AllowRead  bool
+	AllowWrite bool
+	Min        int
+	Max        int
+	Steps      float64
+	Regex      string
+}
+
 func handleIndex(w http.ResponseWriter, r *http.Request) {
 	//Serve the index
 	sendOK(w)
@@ -26,5 +39,47 @@ func handleStatus(w http.ResponseWriter, r *http.Request) {
 }
 
 func handleEndpoints(w http.ResponseWriter, r *http.Request) {
+	endpoints := []Endpoint{}
+	endpoints = append(endpoints, Endpoint{
+		Name:    "Play",
+		RelPath: "play",
+		Desc:    "Toggle player to play or pause",
+		Type:    "none",
+	})
+
+	endpoints = append(endpoints, Endpoint{
+		Name:    "Stop",
+		RelPath: "stop",
+		Desc:    "Stop and flush the buffer of the playing song",
+		Type:    "none",
+	})
+
+	endpoints = append(endpoints, Endpoint{
+		Name:    "Load",
+		RelPath: "load",
+		Desc:    "Load a network resources to play",
+		Type:    "string",
+	})
+
+	endpoints = append(endpoints, Endpoint{
+		Name:    "Volume",
+		RelPath: "vol",
+		Desc:    "Set the volume of the device playback in percentage",
+		Type:    "integer",
+		Max:     100,
+		Min:     0,
+		Steps:   1,
+	})
+
+	endpoints = append(endpoints, Endpoint{
+		Name:    "Jump",
+		RelPath: "jump",
+		Desc:    "Jump to a given location on the track",
+		Type:    "integer",
+		Steps:   1,
+	})
+
+	js, _ := json.Marshal(endpoints)
+	sendJSONResponse(w, string(js))
 
 }