-
Notifications
You must be signed in to change notification settings - Fork 57
/
main.go
82 lines (74 loc) · 2.34 KB
/
main.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package main
import (
"fmt"
"github.com/gorilla/mux"
"keystation/service"
"log"
"net/http"
"os"
)
func main() {
r := mux.NewRouter()
r.Path("/").HandlerFunc(service.IndexHandler)
r.Path("/import").
Queries("client", "{client}").
Queries("lcd", "{lcd}").
Queries("path", "{path}").
Queries("payload", "{payload}").
Queries("option", "{option}").
HandlerFunc(service.ImportHandler).
Methods("GET")
r.Path("/signin").
Queries("client", "{client}").
Queries("lcd", "{lcd}").
Queries("path", "{path}").
Queries("payload", "{payload}").
HandlerFunc(service.SignInHandler).
Methods("GET")
r.Path("/session").
Queries("account", "{account}").
Queries("client", "{client}").
Queries("lcd", "{lcd}").
Queries("path", "{path}").
Queries("payload", "{payload}").
HandlerFunc(service.SessionInHandler).
Methods("GET")
r.Path("/tx").
Queries("account", "{account}").
Queries("client", "{client}").
Queries("lcd", "{lcd}").
Queries("path", "{path}").
Queries("payload", "{payload}").
HandlerFunc(service.TxHandler).
Methods("GET")
r.Path("/setting").
Queries("account", "{account}").
Queries("client", "{client}").
Queries("lcd", "{lcd}").
Queries("path", "{path}").
Queries("payload", "{payload}").
HandlerFunc(service.SettingHandler).
Methods("GET")
// setting?account=booyoun_test&client=https://wallet.cosmostation.io&lcd=https://lcd-cosmos.cosmostation.io&path=44/118/0/0/0&payload=cosmos
// The path "/" matches everything not matched by some other path.
http.Handle("/", r)
favicon := http.StripPrefix("/favicon.ico", http.FileServer(http.Dir("www/img/favicon.ico")))
http.Handle("/favicon.ico", favicon)
lib := http.StripPrefix("/lib", http.FileServer(http.Dir("www/lib")))
http.Handle("/lib/", lib)
js := http.StripPrefix("/js", http.FileServer(http.Dir("www/js")))
http.Handle("/js/", js)
css := http.StripPrefix("/css", http.FileServer(http.Dir("www/css")))
http.Handle("/css/", css)
img := http.StripPrefix("/img", http.FileServer(http.Dir("www/img")))
http.Handle("/img/", img)
fonts := http.StripPrefix("/fonts", http.FileServer(http.Dir("www/fonts")))
http.Handle("/fonts/", fonts)
port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Printf("Defaulting to port %s", port)
}
log.Printf("Listening on port %s", port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%s", port), nil))
}