aboutsummaryrefslogtreecommitdiff
path: root/README.md
diff options
context:
space:
mode:
authorDoug Black <dougblack@gatech.edu>2014-01-25 14:38:03 -0800
committerDoug Black <dougblack@gatech.edu>2014-01-25 14:38:03 -0800
commit777761a8a1be2a8eef9f360ddede7d4dbc7684d2 (patch)
tree0b710b48240d8ef0559c532e1329be2631aee096 /README.md
parentbetter practices (diff)
downloadsleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.tar.gz
sleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.tar.bz2
sleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.zip
update README
Diffstat (limited to 'README.md')
-rw-r--r--README.md38
1 files changed, 20 insertions, 18 deletions
diff --git a/README.md b/README.md
index df45e76..c3fb65b 100644
--- a/README.md
+++ b/README.md
@@ -2,43 +2,45 @@
#### A RESTful framework for Go
-Sleepy is not done yet. Here is a potential target API.
+Sleepy is a micro-framework for building RESTful APIs.
```go
+package main
import (
- "net/http"
+ "net/url"
"sleepy"
)
-type Item struct { }
+type Item struct {
+ 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}
-func (item *Item) Get(foo string, bar int) (interface{}, int, http.Headers) {
- data := map[string]int {
- foo : bar
- }
- return data, 200, nil
+ return 200, data
}
func main() {
- item = new(Item)
+ item := new(Item)
var api = new(sleepy.Api)
- api.AddResource(item, "/item")
-
- request, _ := http.NewRequest("GET", "/item", "foo=thing&bar=5")
- fmt.Println(api.HandleRequest(request))
+ api.AddResource(item, "/items")
+ api.Start(3000)
}
```
-With a response of
+Now if we curl that endpoint:
-```javascript
-{
- "thing": 5
-}
+```bash
+curl localhost:3000/items
+{"items": ["item1", "item2"]}
```
Stay tuned.
bgstack15