aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/test.go b/tests/test.go
new file mode 100644
index 0000000..055067c
--- /dev/null
+++ b/tests/test.go
@@ -0,0 +1,43 @@
+package main
+
+import (
+ "fmt"
+ "sleepy"
+ "net/http"
+)
+
+type Bar struct {
+ sleepy.PostNotSupported
+ sleepy.PutNotSupported
+ sleepy.DeleteNotSupported
+}
+
+func (b Bar) Get(map[string][]string) string {
+ return "Hello"
+}
+
+type Baz struct {
+ sleepy.PostNotSupported
+ sleepy.PutNotSupported
+ sleepy.DeleteNotSupported
+}
+
+func (b Baz) Get(map[string][]string) string {
+ return "Goodbye"
+}
+
+func main() {
+ bar := new(Bar)
+ baz := new(Baz)
+
+ var api = new(sleepy.Api)
+ api.AddResource(bar, "/bar")
+ api.AddResource(baz, "/baz")
+
+ request1, _ := http.NewRequest("GET", "https://dougblack.io/bar", nil)
+ request2, _ := http.NewRequest("GET", "https://dougblack.io/baz", nil)
+ fmt.Println(api.HandleRequest(request1))
+ fmt.Println(api.HandleRequest(request2))
+
+}
+
bgstack15