diff --git a/server.go b/server.go index 2d8fe8e..1690151 100644 --- a/server.go +++ b/server.go @@ -6,6 +6,7 @@ import ( "encoding/xml" "log" "net/http" + "strings" "time" ) @@ -52,13 +53,24 @@ func AreProcessesUp(processes *[]string, indented bool) func(http.ResponseWriter proclist.AddProcess(proc, err == nil && len(pids) > 0) } - if hdr := r.Header.Get("Accept"); hdr == "application/xml" { + hdr := r.Header.Get("Accept") + + if hdr == "application/xml" { w.Header().Add("Content-Type", "application/xml") enc := xml.NewEncoder(w) if indented { enc.Indent("", "\t") } enc.Encode(proclist) + } else if hdr == "text/plain" { + w.Header().Add("Content-Type", "text/plain") + var s []string + for k, v := range *proclist { + if v { + s = append(s, k) + } + } + w.Write([]byte(strings.Join(s, ","))) } else { w.Header().Add("Content-Type", "application/json") enc := json.NewEncoder(w)