/
map.go
54 lines (48 loc) · 1.08 KB
/
map.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
47
48
49
50
51
52
53
54
package resource
import (
"github.com/gbl08ma/sqalx"
"github.com/yarf-framework/yarf"
)
// Map composites resource
type Map struct {
resource
}
// apiMap contains information about a network diagram/map
type apiMap struct {
Type string `msgpack:"type" json:"type"`
}
type apiHTMLMap struct {
apiMap `msgpack:",inline"`
URL string `msgpack:"url" json:"url"`
Cache bool `msgpack:"cache" json:"cache"`
WideViewport bool `msgpack:"wideViewport" json:"wideViewport"`
}
// WithNode associates a sqalx Node with this resource
func (r *Map) WithNode(node sqalx.Node) *Map {
r.node = node
return r
}
// Get serves HTTP GET requests on this resource
func (r *Map) Get(c *yarf.Context) error {
RenderData(c, []interface{}{
apiMap{
Type: "world-map",
},
apiHTMLMap{
apiMap: apiMap{
Type: "html",
},
URL: "mapassets/map-pt-ml.html",
Cache: true,
WideViewport: true,
},
apiHTMLMap{
apiMap: apiMap{
Type: "html",
},
URL: "mapassets/map-pt-ml-portrait.html",
Cache: true,
},
}, "s-maxage=10")
return nil
}