This commit is contained in:
2016-06-30 23:04:34 +05:00
parent 01de887adf
commit 6cf28b9902

View File

@@ -73,6 +73,7 @@ func parseParams(path string) (string, int, int, int, int, int) {
value, _ = strconv.Atoi(params[2]) value, _ = strconv.Atoi(params[2])
} }
if len(params) == 5 { if len(params) == 5 {
value = 0
r, _ = strconv.Atoi(params[2]) r, _ = strconv.Atoi(params[2])
g, _ = strconv.Atoi(params[3]) g, _ = strconv.Atoi(params[3])
b, _ = strconv.Atoi(params[4]) b, _ = strconv.Atoi(params[4])
@@ -101,11 +102,11 @@ func main() {
} }
} else { } else {
http.HandleFunc("/noolite/", func(w http.ResponseWriter, r *http.Request) { http.HandleFunc("/noolite/", func(w http.ResponseWriter, r *http.Request) {
command, channel, _, _,_, _ := parseParams(r.URL.Path[1:]) command, channel, value, r, g, b := parseParams(r.URL.Path[1:])
fmt.Fprintf(w, "Command: %q\n", command) fmt.Fprintf(w, "Command: %q\n", command)
fmt.Fprintf(w, "Channel: %d\n", channel) fmt.Fprintf(w, "Channel: %d\n", channel)
err := sendCommand(command, channel, 0, 0, 0, 0) err := sendCommand(command, channel, value, r, g, b)
if err != nil { if err != nil {
fmt.Fprintf(w, "Error: %q\n", err) fmt.Fprintf(w, "Error: %q\n", err)