diff options
| author | David Hurst | 2016-04-17 12:05:46 -0600 |
|---|---|---|
| committer | David Hurst | 2016-04-17 12:05:46 -0600 |
| commit | 17bff1d0204a766d07ab127152fd006bc302138c (patch) | |
| tree | 9dd71e938901b96cfb6c96f37ec609c21128a89f | |
| parent | 353a3b7151ba1f059bc0275fabf11ca049e7cb52 (diff) | |
| download | torpedo-17bff1d0204a766d07ab127152fd006bc302138c.tar.gz torpedo-17bff1d0204a766d07ab127152fd006bc302138c.zip | |
ping in own file
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | cmd/ping.go | 31 |
2 files changed, 33 insertions, 1 deletions
| @@ -5,4 +5,5 @@ To start dev clone this repo into $GOPATH/src/codesaloon.com/torpedo | |||
| 5 | and start the server with: | 5 | and start the server with: |
| 6 | 6 | ||
| 7 | cd cmd | 7 | cd cmd |
| 8 | go run main.go \ No newline at end of file | 8 | go 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 @@ | |||
| 1 | package main | ||
| 2 | |||
| 3 | import ( | ||
| 4 | "bytes" | ||
| 5 | "codesaloon.com/torpedo" | ||
| 6 | "encoding/xml" | ||
| 7 | "fmt" | ||
| 8 | "net/url" | ||
| 9 | ) | ||
| 10 | |||
| 11 | type ping struct { | ||
| 12 | torpedo.PostNotSupported | ||
| 13 | torpedo.PutNotSupported | ||
| 14 | torpedo.DeleteNotSupported | ||
| 15 | } | ||
| 16 | |||
| 17 | func (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 | } | ||