-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.go
40 lines (30 loc) · 816 Bytes
/
app.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 controllers
import (
"net/http"
"strings"
"io/ioutil"
"github.com/revel/revel"
"github.com/sutthirak/labyrinth/data"
"github.com/sutthirak/labyrinth/renderer"
)
type App struct {
*revel.Controller
}
func (c App) Index() revel.Result {
heavendoor , found := revel.Config.String("heavendoor.url")
if found {
script := renderer.RenderScene(data.GetSceneList())
script = strings.Replace(script,"<script>","",-1)
script = strings.Replace(script,"</script>","",-1)
response , error := http.Post(heavendoor+"/minify","text/plain",strings.NewReader(script))
defer response.Body.Close()
if error == nil {
body, err := ioutil.ReadAll(response.Body)
if err == nil {
script = "<script>" + string(body) + "</script>"
return c.Render(script)
}
}
}
return c.Render()
}