diff options
author | Silvan Jegen <s.jegen@gmail.com> | 2017-02-14 14:31:58 +0100 |
---|---|---|
committer | Silvan Jegen <s.jegen@gmail.com> | 2017-02-14 14:31:58 +0100 |
commit | 543eea285200c8955f42c5eb202a222105259587 (patch) | |
tree | b6c6a16166a16eef2e9fc74fd28240eb66368a50 /output | |
parent | 30716efc96229240cdc1af40ce52d61b0658277b (diff) |
Implement simple http Output
Diffstat (limited to 'output')
-rw-r--r-- | output/http/http.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/output/http/http.go b/output/http/http.go index 9caa1b9..3ea603c 100644 --- a/output/http/http.go +++ b/output/http/http.go @@ -1,7 +1,8 @@ package http import ( - "fmt" + "bytes" + "net/http" "github.com/Shugyousha/stasher/output" "github.com/Shugyousha/stasher/registry" @@ -13,12 +14,17 @@ func init() { } type HttpOutput struct { + url string } -func New(map[string]string) output.Output { - return &HttpOutput{} +func New(kv map[string]string) output.Output { + url := kv["url"] + return &HttpOutput{url: url} } func (h *HttpOutput) Output(w *work.Work) { - fmt.Printf("%s\n", w.Data) + _, err := http.Post(h.url, "application/json", bytes.NewReader(w.Data)) + if err != nil { + w.Err = err + } } |