diff options
author | Doug Black <dougblack@gatech.edu> | 2014-01-25 14:38:03 -0800 |
---|---|---|
committer | Doug Black <dougblack@gatech.edu> | 2014-01-25 14:38:03 -0800 |
commit | 777761a8a1be2a8eef9f360ddede7d4dbc7684d2 (patch) | |
tree | 0b710b48240d8ef0559c532e1329be2631aee096 /README.md | |
parent | better practices (diff) | |
download | sleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.tar.gz sleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.tar.bz2 sleepy-777761a8a1be2a8eef9f360ddede7d4dbc7684d2.zip |
update README
Diffstat (limited to 'README.md')
-rw-r--r-- | README.md | 38 |
1 files changed, 20 insertions, 18 deletions
@@ -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. |