diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-29 23:08:38 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-29 23:08:38 -0800 |
commit | e432bd36da61ac0a498f68fee8785c44ae800cc1 (patch) | |
tree | 5e08626cd7999cecdc5b171aa4e2e409355164b1 /system/api/handlers.go | |
parent | 7418572026f7ec9a35a85baf2cbf24c205740e4c (diff) |
move push func to separate file and adding tidwall/gjson to credits
Diffstat (limited to 'system/api/handlers.go')
-rw-r--r-- | system/api/handlers.go | 31 |
1 files changed, 2 insertions, 29 deletions
diff --git a/system/api/handlers.go b/system/api/handlers.go index a152301..a01f3dc 100644 --- a/system/api/handlers.go +++ b/system/api/handlers.go @@ -11,7 +11,6 @@ import ( "github.com/ponzu-cms/ponzu/system/api/analytics" "github.com/ponzu-cms/ponzu/system/db" "github.com/ponzu-cms/ponzu/system/item" - "github.com/tidwall/gjson" ) func typesHandler(res http.ResponseWriter, req *http.Request) { @@ -99,7 +98,8 @@ func contentHandler(res http.ResponseWriter, req *http.Request) { return } - if pt, ok := item.Types[t]; !ok { + pt, ok := item.Types[t] + if !ok { res.WriteHeader(http.StatusNotFound) return } @@ -183,33 +183,6 @@ func toJSON(data []string) ([]byte, error) { return buf.Bytes(), nil } -func push(res http.ResponseWriter, pt func() interface{}, data []byte) { - // Push(target string, opts *PushOptions) error - if pusher, ok := res.(http.Pusher); ok { - if p, ok := pt().(item.Pushable); ok { - // get fields to pull values from data - fields := p.Push() - - // parse values from data to push - values := gjson.GetManyBytes(data, fields...) - - // push all values from Pushable items' fields - for i := range values { - val := values[i] - val.ForEach(func(k, v gjson.Result) bool { - err := pusher.Push(v.String(), nil) - if err != nil { - log.Println("Error during Push of value:", v.String()) - } - - return true - }) - } - } - } - -} - // sendData() should be used any time you want to communicate // data back to a foreign client func sendData(res http.ResponseWriter, data []byte, code int) { |