aboutsummaryrefslogtreecommitdiff
path: root/tests/test.go
blob: 055067c47d733e055e4af30dc71a084932dff6dc (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
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