diff options
author | Doug Black <dougblack@gatech.edu> | 2014-01-25 19:09:50 -0800 |
---|---|---|
committer | Doug Black <dougblack@gatech.edu> | 2014-01-25 19:09:50 -0800 |
commit | c43ecdc6549b097ec04a427e5afd7a8f6fedc320 (patch) | |
tree | bbac37de060a240e00e566b3fc52be8ab30832b0 /tests | |
parent | update README (diff) | |
download | sleepy-c43ecdc6549b097ec04a427e5afd7a8f6fedc320.tar.gz sleepy-c43ecdc6549b097ec04a427e5afd7a8f6fedc320.tar.bz2 sleepy-c43ecdc6549b097ec04a427e5afd7a8f6fedc320.zip |
cleaner
Diffstat (limited to 'tests')
-rw-r--r-- | tests/items.go | 24 | ||||
-rw-r--r-- | tests/one.go | 14 | ||||
-rw-r--r-- | tests/test.go | 21 |
3 files changed, 36 insertions, 23 deletions
diff --git a/tests/items.go b/tests/items.go index a6f53f6..ee86c3e 100644 --- a/tests/items.go +++ b/tests/items.go @@ -1,29 +1,29 @@ package main import ( - "net/url" - "sleepy" + "net/url" + "sleepy" ) type Item struct { - sleepy.PostNotSupported - sleepy.PutNotSupported - sleepy.DeleteNotSupported + sleepy.PostNotSupported + sleepy.PutNotSupported + sleepy.DeleteNotSupported } func (item Item) Get(values ...url.Values) (int, interface{}) { - items := []string{"item1", "item2"} - data := map[string][]string{"items": items} + items := []string{"item1", "item2"} + data := map[string][]string{"items": items} - return 200, data + return 200, data } func main() { - item := new(Item) + item := new(Item) - var api = new(sleepy.Api) - api.AddResource(item, "/items") - api.Start(3000) + var api = new(sleepy.Api) + api.AddResource(item, "/items") + api.Start(3000) } diff --git a/tests/one.go b/tests/one.go new file mode 100644 index 0000000..15fd27b --- /dev/null +++ b/tests/one.go @@ -0,0 +1,14 @@ +package main + +import ( + "net/http" +) + +func response(rw http.ResponseWriter, request *http.Request) { + rw.Write([]byte("Hello world.")) +} + +func main() { + http.HandleFunc("/", response) + http.ListenAndServe(":3000", nil) +} diff --git a/tests/test.go b/tests/test.go index 4610f3d..d225072 100644 --- a/tests/test.go +++ b/tests/test.go @@ -1,25 +1,24 @@ package main import ( - "sleepy" - "net/url" + "net/url" + "sleepy" ) type Bar struct { - sleepy.PostNotSupported - sleepy.PutNotSupported - sleepy.DeleteNotSupported + sleepy.PostNotSupported + sleepy.PutNotSupported + sleepy.DeleteNotSupported } func (b Bar) Get(values ...url.Values) (int, interface{}) { - return 200, map[string]string{"hello": "goodbye"} + return 200, map[string]string{"hello": "goodbye"} } func main() { - bar := new(Bar) + bar := new(Bar) - var api = new(sleepy.Api) - api.AddResource(bar, "/bar") - api.Start(3000) + var api = new(sleepy.Api) + api.AddResource(bar, "/bar") + api.Start(3000) } - |