summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/filterinterface.go (renamed from filter/interface.go)0
-rw-r--r--filter/http/http.go (renamed from filter/http.go)11
-rw-r--r--filter/str/string.go (renamed from filter/string.go)4
-rw-r--r--main.go4
-rw-r--r--registry/registry.go7
5 files changed, 15 insertions, 11 deletions
diff --git a/filter/interface.go b/filter/filterinterface.go
index 83d2dfe..83d2dfe 100644
--- a/filter/interface.go
+++ b/filter/filterinterface.go
diff --git a/filter/http.go b/filter/http/http.go
index 97fffa7..e3d447b 100644
--- a/filter/http.go
+++ b/filter/http/http.go
@@ -1,18 +1,25 @@
-package filter
+package http
import (
"bytes"
"io/ioutil"
"net/http"
+ "github.com/Shugyousha/stasher/filter"
+ "github.com/Shugyousha/stasher/registry"
"github.com/Shugyousha/stasher/work"
)
+func init() {
+ registry.Filterregistry["http"] = New
+}
+
type HTTPFilter struct {
url string
}
-func NewHTTPFilter(url string) *HTTPFilter {
+func New(kv map[string]string) filter.Filter {
+ url := kv["url"]
return &HTTPFilter{url: url}
}
diff --git a/filter/string.go b/filter/str/string.go
index cb44d75..0ae407d 100644
--- a/filter/string.go
+++ b/filter/str/string.go
@@ -1,4 +1,4 @@
-package filter
+package str
import (
"bytes"
@@ -13,7 +13,7 @@ type StringFilter struct {
FilterFuncMap map[string]func(string) string
}
-func NewStringFilter(ffmap map[string]func(string) string) *StringFilter {
+func New(ffmap map[string]func(string) string) *StringFilter {
return &StringFilter{FilterFuncMap: ffmap}
}
diff --git a/main.go b/main.go
index a52b5ac..5b0e329 100644
--- a/main.go
+++ b/main.go
@@ -7,7 +7,7 @@ import (
"strings"
"github.com/Shugyousha/stasher/conf"
- "github.com/Shugyousha/stasher/filter"
+ "github.com/Shugyousha/stasher/filter/str"
"github.com/Shugyousha/stasher/input/stdin"
"github.com/Shugyousha/stasher/output"
)
@@ -27,7 +27,7 @@ func main() {
m := Manager{
Input: stdin.New(nil),
- Filter: filter.NewStringFilter(ffmap),
+ Filter: str.New(ffmap),
Output: &output.StdoutOutput{},
}
diff --git a/registry/registry.go b/registry/registry.go
index 5b285b8..bdf841d 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -2,19 +2,16 @@ package registry
import (
"github.com/Shugyousha/stasher/input"
+ "github.com/Shugyousha/stasher/filter"
"github.com/Shugyousha/stasher/work"
)
var (
Inputregistry map[string]func(map[string]string) input.Input
- Filterregistry map[string]func(map[string]string) Filter
+ Filterregistry map[string]func(map[string]string) filter.Filter
Outputregistry map[string]func(map[string]string) Output
)
-type Filter interface {
- Filter(*work.Work) *work.Work
-}
-
type Output interface {
Output(*work.Work)
}