-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrequest.go
67 lines (55 loc) · 1.45 KB
/
request.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
55
56
57
58
59
60
61
62
63
64
65
66
67
package veldt
import (
"strings"
"github.com/davecgh/go-spew/spew"
"github.com/unchartedsoftware/veldt/binning"
)
var (
spewer *spew.ConfigState
)
func init() {
spewer = &spew.ConfigState{
Indent: "",
MaxDepth: 0,
DisableMethods: true,
DisablePointerMethods: true,
DisablePointerAddresses: true,
DisableCapacities: true,
ContinueOnMethod: false,
SortKeys: true,
SpewKeys: true,
}
}
// Request represents a basic request interface.
type Request interface {
Create() ([]byte, error)
GetHash() string
}
// TileRequest represents a tile data generation request.
type TileRequest struct {
URI string
Coord *binning.TileCoord
Query Query
Tile Tile
}
// Create generates and returns the tile for the request.
func (r *TileRequest) Create() ([]byte, error) {
return r.Tile.Create(r.URI, r.Coord, r.Query)
}
// GetHash returns a unique hash for the request.
func (r *TileRequest) GetHash() string {
return strings.Join(strings.Fields(spewer.Sdump(r)), "")
}
// MetaRequest represents a meta data generation request.
type MetaRequest struct {
URI string
Meta Meta
}
// Create generates and returns the meta data for the request.
func (r *MetaRequest) Create() ([]byte, error) {
return r.Meta.Create(r.URI)
}
// GetHash returns a unique hash for the request.
func (r *MetaRequest) GetHash() string {
return strings.Join(strings.Fields(spewer.Sdump(r)), "")
}