parent
55730270e5
commit
40c3465ec5
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
// Router provides handlers for each transaction type.
|
// Router provides handlers for each transaction type.
|
||||||
type Router interface {
|
type Router interface {
|
||||||
AddRoute(r string, h sdk.Handler)
|
AddRoute(r string, h sdk.Handler) (rtr Router)
|
||||||
Route(path string) (h sdk.Handler)
|
Route(path string) (h sdk.Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,13 @@ func NewRouter() *router {
|
||||||
var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString
|
var isAlpha = regexp.MustCompile(`^[a-zA-Z]+$`).MatchString
|
||||||
|
|
||||||
// AddRoute - TODO add description
|
// AddRoute - TODO add description
|
||||||
func (rtr *router) AddRoute(r string, h sdk.Handler) {
|
func (rtr *router) AddRoute(r string, h sdk.Handler) Router {
|
||||||
if !isAlpha(r) {
|
if !isAlpha(r) {
|
||||||
panic("route expressions can only contain alphanumeric characters")
|
panic("route expressions can only contain alphanumeric characters")
|
||||||
}
|
}
|
||||||
rtr.routes = append(rtr.routes, route{r, h})
|
rtr.routes = append(rtr.routes, route{r, h})
|
||||||
|
|
||||||
|
return rtr
|
||||||
}
|
}
|
||||||
|
|
||||||
// Route - TODO add description
|
// Route - TODO add description
|
||||||
|
|
|
@ -53,8 +53,9 @@ func NewBasecoinApp(logger log.Logger, db dbm.DB) *BasecoinApp {
|
||||||
|
|
||||||
// add handlers
|
// add handlers
|
||||||
coinKeeper := bank.NewCoinKeeper(app.accountMapper)
|
coinKeeper := bank.NewCoinKeeper(app.accountMapper)
|
||||||
app.Router().AddRoute("bank", bank.NewHandler(coinKeeper))
|
app.Router().
|
||||||
app.Router().AddRoute("sketchy", sketchy.NewHandler())
|
AddRoute("bank", bank.NewHandler(coinKeeper)).
|
||||||
|
AddRoute("sketchy", sketchy.NewHandler())
|
||||||
|
|
||||||
// initialize BaseApp
|
// initialize BaseApp
|
||||||
app.SetTxDecoder(app.txDecoder)
|
app.SetTxDecoder(app.txDecoder)
|
||||||
|
|
Loading…
Reference in New Issue