diff options
Diffstat (limited to 'hyper/process')
-rw-r--r-- | hyper/process/main.go | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/hyper/process/main.go b/hyper/process/main.go index ebeeb6d6..5420f681 100644 --- a/hyper/process/main.go +++ b/hyper/process/main.go @@ -6,6 +6,7 @@ import "http" import "gorilla.googlecode.com/hg/gorilla/mux" import "os" import "fmt" +import "bytes" import "hyper/process" @@ -47,13 +48,29 @@ func RetrieveProcess(res http.ResponseWriter, req *http.Request) { } } +func FeedProcess(res http.ResponseWriter, req *http.Request) { + if p := proc[mux.Vars(req)["id"]]; p != nil { + body := make([]byte, 4096) + if _, err := req.Body.Read(body); err == nil { + body = bytes.TrimRight(body, string([]byte{0})) + p.Write(body) + //if err := p.Write(body); err == nil { + RespondJSON(res, true) + //} + } + } else { + res.WriteHeader(http.StatusNotFound) + } +} + func main() { // Gorilla mux.HandleFunc("/proc", CreateProcessHandler).Methods("POST") mux.HandleFunc("/proc/{id}", RetrieveProcess).Methods("GET") + mux.HandleFunc("/proc/{id}", FeedProcess).Methods("POST") - err := http.ListenAndServe(":8888", mux.DefaultRouter) + err := http.ListenAndServe("0.0.0.0:8888", mux.DefaultRouter) if err != nil { log.Fatal("ListenAndServe: ", err.String()) } |