From 543eea285200c8955f42c5eb202a222105259587 Mon Sep 17 00:00:00 2001 From: Silvan Jegen Date: Tue, 14 Feb 2017 14:31:58 +0100 Subject: Implement simple http Output --- output/http/http.go | 14 ++++++++++---- 1 file 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 + } } -- cgit v1.2.3