-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathfireball.go
40 lines (36 loc) · 905 Bytes
/
fireball.go
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
package main
import (
"fmt"
"github.com/zpatrick/fireball"
)
func init() {
calcMem("fireball", initFireball)
}
func initFireball() {
routes := []*fireball.Route{
&fireball.Route{
Path: "/",
Handlers: fireball.Handlers{
"GET": func(c *fireball.Context) (fireball.Response, error) {
return fireball.NewResponse(200, []byte("Hello, World"), map[string]string{
"Content-Type": "text/plain; charset=utf-8",
}), nil
},
},
},
&fireball.Route{
Path: "/:name",
Handlers: fireball.Handlers{
"GET": func(c *fireball.Context) (fireball.Response, error) {
name := c.PathVariables["name"]
body := fmt.Sprintf("Hello, %s", name)
return fireball.NewResponse(200, []byte(body), map[string]string{
"Content-Type": "text/plain; charset=utf-8",
}), nil
},
},
},
}
app := fireball.NewApp(routes)
registerHandler("fireball", app)
}