aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Hurst2016-04-17 12:05:46 -0600
committerDavid Hurst2016-04-17 12:05:46 -0600
commit17bff1d0204a766d07ab127152fd006bc302138c (patch)
tree9dd71e938901b96cfb6c96f37ec609c21128a89f
parent353a3b7151ba1f059bc0275fabf11ca049e7cb52 (diff)
downloadtorpedo-17bff1d0204a766d07ab127152fd006bc302138c.tar.gz
torpedo-17bff1d0204a766d07ab127152fd006bc302138c.zip
ping in own file
-rw-r--r--README.md3
-rw-r--r--cmd/ping.go31
2 files changed, 33 insertions, 1 deletions
diff --git a/README.md b/README.md
index 0fc2fa8..2bf167b 100644
--- a/README.md
+++ b/README.md
@@ -5,4 +5,5 @@ To start dev clone this repo into $GOPATH/src/codesaloon.com/torpedo
5and start the server with: 5and start the server with:
6 6
7cd cmd 7cd cmd
8go run main.go \ No newline at end of file 8go build -o serve
9./serve \ No newline at end of file
diff --git a/cmd/ping.go b/cmd/ping.go
new file mode 100644
index 0000000..a046cb0
--- /dev/null
+++ b/cmd/ping.go
@@ -0,0 +1,31 @@
1package main
2
3import (
4 "bytes"
5 "codesaloon.com/torpedo"
6 "encoding/xml"
7 "fmt"
8 "net/url"
9)
10
11type ping struct {
12 torpedo.PostNotSupported
13 torpedo.PutNotSupported
14 torpedo.DeleteNotSupported
15}
16
17func (ping) Get(values url.Values) (int, string) {
18
19 data := &subsonicresponse{Version: "1.1.1", Status: "ok", Xmlns: "http://subsonic.org/restapi"}
20
21 buf := new(bytes.Buffer)
22 enc := xml.NewEncoder(buf)
23
24 if err := enc.Encode(data); err != nil {
25 fmt.Printf("error: %v\n", err)
26 } else {
27 fmt.Println(buf.String())
28 }
29
30 return 200, buf.String()
31}