From d4b94e4b37bb4b28dae2a91bf4a9872e0a801c1a Mon Sep 17 00:00:00 2001 From: Steve Manuel Date: Sat, 17 Dec 2016 06:05:07 -0800 Subject: moving reference into content package and testing API based approach --- system/api/server.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'system/api/server.go') diff --git a/system/api/server.go b/system/api/server.go index 823ec16..7254a7b 100644 --- a/system/api/server.go +++ b/system/api/server.go @@ -1,6 +1,9 @@ package api import ( + "bytes" + "fmt" + "log" "net/http" ) @@ -14,3 +17,22 @@ func Run() { http.HandleFunc("/api/content/external", CORS(Record(externalContentHandler))) } + +// ContentAll retrives all items from the HTTP API within the provided namespace +func ContentAll(namespace string) [][]bytes { + endpoint := "http://0.0.0.0:8080/api/contents?type=" + buf := []byte{} + r := bytes.NewReader(buf) + req, err := http.NewRequest(http.MethodGet, endpoint+namespace, r) + if err != nil { + log.Println("Error creating request for reference from:", contentType) + return nil + } + + c := http.Client{} + res, err := c.Do(req) + + fmt.Println(res, string(buf)) + + return []byte{buf} +} -- cgit v1.2.3