forked from kyleconroy/deckbrew
-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.go
44 lines (34 loc) · 971 Bytes
/
router.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
package brew
import (
"fmt"
"strings"
"github.com/kyleconroy/deckbrew/config"
)
type router struct {
cfg *config.Config
}
func base(host string) string {
if strings.Contains(host, ":") {
return "http://" + host
} else {
return "https://" + host
}
}
func (r router) CardURL(id string) string {
return fmt.Sprintf("%s/mtg/cards/%s", base(r.cfg.HostAPI), id)
}
func (r router) EditionURL(id int) string {
return fmt.Sprintf("%s/mtg/cards?multiverseid=%d", base(r.cfg.HostAPI), id)
}
func (r router) SetURL(id string) string {
return fmt.Sprintf("%s/mtg/sets/%s", base(r.cfg.HostAPI), id)
}
func (r router) SetCardsURL(id string) string {
return fmt.Sprintf("%s/mtg/cards?set=%s", base(r.cfg.HostAPI), id)
}
func (r router) EditionImageURL(id int) string {
return fmt.Sprintf("%s/mtg/multiverseid/%d.jpg", base(r.cfg.HostImage), id)
}
func (r router) EditionHtmlURL(id int) string {
return fmt.Sprintf("%s/mtg/cards/%d", base(r.cfg.HostWeb), id)
}