-
Notifications
You must be signed in to change notification settings - Fork 0
/
routes.go
46 lines (40 loc) · 1.08 KB
/
routes.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
41
42
43
44
45
46
package app
import (
"fmt"
"github.com/h2object/h2object/httpext"
)
var ItWorks string = `
<html>
<head>
<title>h2object running</title>
</head>
<body style="margin: 0px 0px 0px 0px; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;">
<div style="background-color:#A9F16C; min-height: 360px;">
<br><br>
<div style="width: 360px; margin-right: auto; margin-left: auto;">
<h1 style="font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 60px;line-height: 1;">It works!</h1>
<br>
<p>h2object current version: %s</p>
</div>
</div>
</body>
</html>
`
func routes_filter(ctx *context, c *ext.Controller, filters []filter) {
if done := routes(ctx, c); done {
ctx.Info("request (%s) (%s) done by routes", c.Request.MethodToLower(), c.Request.URI())
return
}
filters[0](ctx, c, filters[1:])
}
func routes(ctx *context, c *ext.Controller) bool {
if c.Request.URI() == "/" {
c.Html(fmt.Sprintf(ItWorks, ctx.app.version))
return true
}
if c.Request.URI() == "/stats" {
c.Json(ctx.app.statistics.Data())
return true
}
return false
}