-
Notifications
You must be signed in to change notification settings - Fork 0
/
spud_example.go
43 lines (34 loc) · 954 Bytes
/
spud_example.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import "fmt"
import "time"
import "github.com/chris-wood/spud/stack/spud"
import "github.com/chris-wood/spud/stack/api/store"
import "github.com/chris-wood/spud/stack/api/portal"
var count = 0
var done chan int
func displayResponse(response []byte) {
fmt.Println("Response: " + string(response))
count = 1
}
func generateResponse(name string, response []byte) []byte {
fmt.Println("here's the response")
return []byte("hello, spud!")
}
func testStack() {
myStack, err := spud.CreateRaw(`{"connector": "athena", "link": "loopback", "fwd-address": "127.0.0.1:9696", "keys": ["key.p12"]}`)
if err != nil {
panic("Could not create the stack")
}
p := portal.NewPortal(myStack)
storer := store.NewStoreAPI(p)
storer.Serve("ccnx:/hello/spud", generateResponse)
data, err := storer.Get("ccnx:/hello/spud", time.Second)
if err != nil {
fmt.Println(err)
} else {
fmt.Println(string(data))
}
}
func main() {
testStack()
}