summaryrefslogtreecommitdiff
path: root/input
diff options
context:
space:
mode:
Diffstat (limited to 'input')
-rw-r--r--input/http/http.go (renamed from input/http.go)20
-rw-r--r--input/inputinterface.go (renamed from input/interface.go)0
-rw-r--r--input/stdin/stdin.go (renamed from input/stdin.go)10
3 files changed, 26 insertions, 4 deletions
diff --git a/input/http.go b/input/http/http.go
index 285f1f6..71a0340 100644
--- a/input/http.go
+++ b/input/http/http.go
@@ -1,20 +1,36 @@
-package input
+package http
import (
"fmt"
"io/ioutil"
"net/http"
+ "github.com/Shugyousha/stasher/input"
+ "github.com/Shugyousha/stasher/registry"
"github.com/Shugyousha/stasher/work"
)
+func init() {
+ registry.Inputregistry["http"] = New
+}
+
type HTTPInput struct {
retchan chan *work.Work
prefix string
port string
}
-func NewHTTPInput(prefix, port string) *HTTPInput {
+func New(conf map[string]string) input.Input {
+ prefix := conf["prefix"]
+ if prefix == "" {
+ fmt.Printf("Need a prefix when setting up http input\n")
+ return nil
+ }
+ port := conf["port"]
+ if port == "" {
+ fmt.Printf("Need a port number when setting up http input\n")
+ return nil
+ }
return &HTTPInput{prefix: prefix, port: port}
}
diff --git a/input/interface.go b/input/inputinterface.go
index 1743249..1743249 100644
--- a/input/interface.go
+++ b/input/inputinterface.go
diff --git a/input/stdin.go b/input/stdin/stdin.go
index 25840ef..fa4d21f 100644
--- a/input/stdin.go
+++ b/input/stdin/stdin.go
@@ -1,4 +1,4 @@
-package input
+package stdin
import (
"bufio"
@@ -6,14 +6,20 @@ import (
"io"
"os"
+ "github.com/Shugyousha/stasher/input"
+ "github.com/Shugyousha/stasher/registry"
"github.com/Shugyousha/stasher/work"
)
+func init() {
+ registry.Inputregistry["input"] = New
+}
+
type StdinInput struct {
retchan chan *work.Work
}
-func NewStdin() *StdinInput {
+func New(map[string]string) input.Input {
return &StdinInput{}
}