aboutsummaryrefslogtreecommitdiff
path: root/README.md
blob: 2d4b141a27a88297141e4a3c8835e9791b3fc48a (plain)
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
44
## Sleepy

#### A RESTful framework for Go

Sleepy is not done yet.  Here is a potential target API.

```go

import (
    "net/http"
    "sleepy"
)

type Item struct { }

func (item *Item) Get(foo string, bar int) (interface{}, int, http.Headers) {
    data := map[string]int {
        foo : bar
    }
    return data, 200, nil
}

func main() {

    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))

}
```

With a response of

``javascript
{
    "thing": 5
}
```

Stay tuned.
bgstack15