Skip to content

Commit 58a17e9

Browse files
author
Booyoun-Kim
committed
fixed folder structure and updated to v0.5.6(cosmosjs) with checksum.
1 parent caf5aca commit 58a17e9

File tree

6 files changed

+59
-52
lines changed

6 files changed

+59
-52
lines changed

app.yaml

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
runtime: go111
1+
runtime: go112
22

33
handlers:
4-
- url: /favicon.ico
5-
static_dir: www/img/favicon.ico
64
- url: /www
7-
static_dir: www
8-
- url: /lib
9-
static_dir: www/lib
10-
- url: /js
11-
static_dir: www/js
12-
- url: /css
13-
static_dir: www/css
14-
- url: /img
15-
static_dir: www/img
16-
- url: /fonts
17-
static_dir: www/fonts
5+
static_files: www
6+
upload: www
7+
188
- url: /.*
9+
secure: always
10+
redirect_http_response_code: 301
1911
script: auto
20-
secure: always

main.go

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,64 @@ package main
22

33
import (
44
"fmt"
5-
"html/template"
65
"log"
76
"net/http"
87
"github.com/gorilla/mux"
98
"os"
10-
)
11-
12-
var (
13-
indexTemplate = template.Must(template.ParseFiles("www/index.html"))
14-
importTemplate = template.Must(template.ParseFiles("www/import.html"))
15-
signInTemplate = template.Must(template.ParseFiles("www/signin.html"))
16-
sessionTemplate = template.Must(template.ParseFiles("www/session.html"))
17-
txTemplate = template.Must(template.ParseFiles("www/transaction.html"))
9+
"keystation/service"
1810
)
1911

2012
func main() {
2113
r := mux.NewRouter()
2214

23-
r.Path("/").HandlerFunc(indexHandler)
15+
r.Path("/").HandlerFunc(service.IndexHandler)
2416
r.Path("/import").
2517
Queries("client", "{client}").
2618
Queries("lcd", "{lcd}").
2719
Queries("path", "{path}").
2820
Queries("payload", "{payload}").
29-
HandlerFunc(importHandler).
21+
HandlerFunc(service.ImportHandler).
3022
Methods("GET")
3123
r.Path("/signin").
3224
Queries("client", "{client}").
3325
Queries("lcd", "{lcd}").
3426
Queries("path", "{path}").
3527
Queries("payload", "{payload}").
36-
HandlerFunc(signInHandler).
28+
HandlerFunc(service.SignInHandler).
3729
Methods("GET")
3830
r.Path("/session").
3931
Queries("account", "{account}").
4032
Queries("client", "{client}").
4133
Queries("lcd", "{lcd}").
4234
Queries("path", "{path}").
4335
Queries("payload", "{payload}").
44-
HandlerFunc(sessionInHandler).
36+
HandlerFunc(service.SessionInHandler).
4537
Methods("GET")
4638
r.Path("/tx").
4739
Queries("account", "{account}").
4840
Queries("client", "{client}").
4941
Queries("lcd", "{lcd}").
5042
Queries("path", "{path}").
5143
Queries("payload", "{payload}").
52-
HandlerFunc(txHandler).
44+
HandlerFunc(service.TxHandler).
5345
Methods("GET")
5446

5547
// The path "/" matches everything not matched by some other path.
5648
http.Handle("/", r)
5749

50+
favicon := http.StripPrefix("/favicon.ico", http.FileServer(http.Dir("www/img/favicon.ico")))
51+
http.Handle("/favicon.ico", favicon)
52+
lib := http.StripPrefix("/lib", http.FileServer(http.Dir("www/lib")))
53+
http.Handle("/lib/", lib)
54+
js := http.StripPrefix("/js", http.FileServer(http.Dir("www/js")))
55+
http.Handle("/js/", js)
56+
css := http.StripPrefix("/css", http.FileServer(http.Dir("www/css")))
57+
http.Handle("/css/", css)
58+
img := http.StripPrefix("/img", http.FileServer(http.Dir("www/img")))
59+
http.Handle("/img/", img)
60+
fonts := http.StripPrefix("/fonts", http.FileServer(http.Dir("www/fonts")))
61+
http.Handle("/fonts/", fonts)
62+
5863
port := os.Getenv("PORT")
5964
if port == "" {
6065
port = "8080"

model.go renamed to model/model.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
package main
1+
package model
22

33
import "html/template"
44

5-
type signInTemplateParams struct {
5+
type SignInTemplateParams struct {
66
QueryUrl string
77
Lcd string
88
Payload string
99
ShuffledNumCode template.HTML
1010
ShuffledAlphabetCode template.HTML
1111
}
1212

13-
type importTemplateParams struct {
13+
type ImportTemplateParams struct {
1414
QueryUrl string
1515
Client string
1616
Lcd string
@@ -20,7 +20,7 @@ type importTemplateParams struct {
2020
ShuffledAlphabetCode template.HTML
2121
}
2222

23-
type sessionTemplateParams struct {
23+
type SessionTemplateParams struct {
2424
QueryUrl string
2525
Payload string
2626
Account string
@@ -34,7 +34,7 @@ type ImportForm struct {
3434
Payload string
3535
}
3636

37-
type txTemplateParams struct {
37+
type TxTemplateParams struct {
3838
Account string
3939
Client string
4040
Lcd string

service.go renamed to service/service.go

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
1-
package main
1+
package service
22

33
import (
44
"github.com/gorilla/mux"
55
"html/template"
66
"net/http"
77
"net/url"
88
"strings"
9+
"keystation/model"
10+
"keystation/util"
911
)
1012

11-
func indexHandler(w http.ResponseWriter, r *http.Request) {
13+
var (
14+
indexTemplate = template.Must(template.ParseFiles("www/index.html"))
15+
importTemplate = template.Must(template.ParseFiles("www/import.html"))
16+
signInTemplate = template.Must(template.ParseFiles("www/signin.html"))
17+
sessionTemplate = template.Must(template.ParseFiles("www/session.html"))
18+
txTemplate = template.Must(template.ParseFiles("www/transaction.html"))
19+
)
20+
21+
func IndexHandler(w http.ResponseWriter, r *http.Request) {
1222
if r.URL.Path != "/" {
1323
http.Redirect(w, r, "/", http.StatusFound)
1424
return
@@ -18,7 +28,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
1828
return
1929
}
2030

21-
func importHandler(w http.ResponseWriter, r *http.Request) {
31+
func ImportHandler(w http.ResponseWriter, r *http.Request) {
2232
vars := mux.Vars(r)
2333

2434
client, err := url.QueryUnescape(vars["client"])
@@ -45,20 +55,20 @@ func importHandler(w http.ResponseWriter, r *http.Request) {
4555
return
4656
}
4757

48-
params := importTemplateParams{}
58+
params := model.ImportTemplateParams{}
4959
params.QueryUrl = "signin?client=" + url.QueryEscape(client) + "&lcd=" + url.QueryEscape(lcd) + "&path=" + url.QueryEscape(path) + "&payload=" + url.QueryEscape(payload)
5060
params.Client = client
5161
params.Lcd = lcd
5262
params.Path = path
5363
params.Payload = payload
54-
params.ShuffledNumCode = template.HTML(GetShuffledNum()) // Keypad of shuffled number
55-
params.ShuffledAlphabetCode = template.HTML(GetShuffledAlphabet()) // Keypad of shuffled alphabet
64+
params.ShuffledNumCode = template.HTML(util.GetShuffledNum()) // Keypad of shuffled number
65+
params.ShuffledAlphabetCode = template.HTML(util.GetShuffledAlphabet()) // Keypad of shuffled alphabet
5666

5767
importTemplate.Execute(w, params)
5868
return
5969
}
6070

61-
func signInHandler(w http.ResponseWriter, r *http.Request) {
71+
func SignInHandler(w http.ResponseWriter, r *http.Request) {
6272
vars := mux.Vars(r)
6373

6474
client, err := url.QueryUnescape(vars["client"])
@@ -85,19 +95,19 @@ func signInHandler(w http.ResponseWriter, r *http.Request) {
8595
return
8696
}
8797

88-
params := signInTemplateParams{}
98+
params := model.SignInTemplateParams{}
8999
params.QueryUrl = "import?client=" + url.QueryEscape(client) + "&lcd=" + url.QueryEscape(lcd) + "&path=" + url.QueryEscape(path) + "&payload=" + url.QueryEscape(payload)
90100
params.Lcd = lcd
91-
params.ShuffledNumCode = template.HTML(GetShuffledNum()) // Keypad of shuffled number
92-
params.ShuffledAlphabetCode = template.HTML(GetShuffledAlphabet()) // Keypad of shuffled alphabet
101+
params.ShuffledNumCode = template.HTML(util.GetShuffledNum()) // Keypad of shuffled number
102+
params.ShuffledAlphabetCode = template.HTML(util.GetShuffledAlphabet()) // Keypad of shuffled alphabet
93103

94104
signInTemplate.Execute(w, params)
95105
return
96106
}
97107

98-
func sessionInHandler(w http.ResponseWriter, r *http.Request) {
108+
func SessionInHandler(w http.ResponseWriter, r *http.Request) {
99109
// HTML Form
100-
importForm := ImportForm{
110+
importForm := model.ImportForm{
101111
Account: r.FormValue("account"),
102112
Client: r.FormValue("client"),
103113
Path: r.FormValue("path"),
@@ -143,7 +153,7 @@ func sessionInHandler(w http.ResponseWriter, r *http.Request) {
143153
}
144154
}
145155

146-
params := sessionTemplateParams{}
156+
params := model.SessionTemplateParams{}
147157
params.QueryUrl = "import?client=" + url.QueryEscape(client) + "&lcd=" + url.QueryEscape(lcd) + "&path=" + url.QueryEscape(path) + "&payload=" + url.QueryEscape(payloadForQuery)
148158
params.Payload = payload // address
149159
params.Account = account // keychain account
@@ -152,7 +162,7 @@ func sessionInHandler(w http.ResponseWriter, r *http.Request) {
152162
return
153163
}
154164

155-
func txHandler(w http.ResponseWriter, r *http.Request) {
165+
func TxHandler(w http.ResponseWriter, r *http.Request) {
156166
vars := mux.Vars(r)
157167

158168
account, err := url.QueryUnescape(vars["account"])
@@ -186,14 +196,14 @@ func txHandler(w http.ResponseWriter, r *http.Request) {
186196
return
187197
}
188198

189-
params := txTemplateParams{}
199+
params := model.TxTemplateParams{}
190200
params.Account = account
191201
params.Client = client
192202
params.Lcd = lcd
193203
params.Path = path
194204
params.Payload = payload
195-
params.ShuffledNumCode = template.HTML(GetShuffledNum()) // Keypad of shuffled number
196-
params.ShuffledAlphabetCode = template.HTML(GetShuffledAlphabet()) // Keypad of shuffled alphabet
205+
params.ShuffledNumCode = template.HTML(util.GetShuffledNum()) // Keypad of shuffled number
206+
params.ShuffledAlphabetCode = template.HTML(util.GetShuffledAlphabet()) // Keypad of shuffled alphabet
197207

198208
txTemplate.Execute(w, params)
199209
return

util.go renamed to util/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package main
1+
package util
22

33
import (
44
"math/rand"

www/js/bundle.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
2+
23
const cosmosjs = require("../src");
34

45
getKeyStationMainAddress = function (mnemonic, hdPath, prefix) {

0 commit comments

Comments
 (0)