diff --git a/baseapp/abci.go b/baseapp/abci.go index 4fa777d3ab..e843b99c75 100644 --- a/baseapp/abci.go +++ b/baseapp/abci.go @@ -391,8 +391,8 @@ func handleQueryCustom(app *BaseApp, path []string, req abci.RequestQuery) (res // path[0] should be "custom" because "/custom" prefix is required for keeper // queries. // - // The queryRouter routes using path[1]. For example, in the path - // "custom/gov/proposal", queryRouter routes using "gov". + // The QueryRouter routes using path[1]. For example, in the path + // "custom/gov/proposal", QueryRouter routes using "gov". if len(path) < 2 || path[1] == "" { return sdk.ErrUnknownRequest("No route for custom query specified").QueryResult() } diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 7f16fe7522..4fc78546bf 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -358,7 +358,7 @@ func (app *BaseApp) setInterBlockCache(cache sdk.MultiStorePersistentCache) { // Router returns the router of the BaseApp. func (app *BaseApp) Router() sdk.Router { if app.sealed { - // We cannot return a router when the app is sealed because we can't have + // We cannot return a Router when the app is sealed because we can't have // any routes modified which would cause unexpected routing behavior. panic("Router() on sealed BaseApp") } diff --git a/baseapp/helpers.go b/baseapp/helpers.go index 349f7775f3..5ea3cdcd9a 100644 --- a/baseapp/helpers.go +++ b/baseapp/helpers.go @@ -10,12 +10,10 @@ import ( var isAlphaNumeric = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString -// Mostly for testing func (app *BaseApp) Check(tx sdk.Tx) (result sdk.Result) { return app.runTx(runTxModeCheck, nil, tx) } -// full tx execution func (app *BaseApp) Simulate(txBytes []byte, tx sdk.Tx) (result sdk.Result) { return app.runTx(runTxModeSimulate, txBytes, tx) } diff --git a/baseapp/options.go b/baseapp/options.go index ba4cf26927..632a978506 100644 --- a/baseapp/options.go +++ b/baseapp/options.go @@ -1,4 +1,3 @@ -// nolint: golint package baseapp import ( diff --git a/baseapp/queryrouter.go b/baseapp/queryrouter.go index 9e38674def..fbefda4a8d 100644 --- a/baseapp/queryrouter.go +++ b/baseapp/queryrouter.go @@ -6,24 +6,22 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type queryRouter struct { +type QueryRouter struct { routes map[string]sdk.Querier } var _ sdk.QueryRouter = NewQueryRouter() -// NewQueryRouter returns a reference to a new queryRouter. -// -// TODO: Either make the function private or make return type (queryRouter) public. -func NewQueryRouter() *queryRouter { // nolint: golint - return &queryRouter{ +// NewQueryRouter returns a reference to a new QueryRouter. +func NewQueryRouter() *QueryRouter { + return &QueryRouter{ routes: map[string]sdk.Querier{}, } } // AddRoute adds a query path to the router with a given Querier. It will panic // if a duplicate route is given. The route must be alphanumeric. -func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter { +func (qrt *QueryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter { if !isAlphaNumeric(path) { panic("route expressions can only contain alphanumeric characters") } @@ -36,6 +34,6 @@ func (qrt *queryRouter) AddRoute(path string, q sdk.Querier) sdk.QueryRouter { } // Route returns the Querier for a given query route path. -func (qrt *queryRouter) Route(path string) sdk.Querier { +func (qrt *QueryRouter) Route(path string) sdk.Querier { return qrt.routes[path] } diff --git a/baseapp/router.go b/baseapp/router.go index 9eebce2394..96386e6edd 100644 --- a/baseapp/router.go +++ b/baseapp/router.go @@ -6,24 +6,22 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -type router struct { +type Router struct { routes map[string]sdk.Handler } var _ sdk.Router = NewRouter() // NewRouter returns a reference to a new router. -// -// TODO: Either make the function private or make return type (router) public. -func NewRouter() *router { // nolint: golint - return &router{ +func NewRouter() *Router { + return &Router{ routes: make(map[string]sdk.Handler), } } // AddRoute adds a route path to the router with a given handler. The route must // be alphanumeric. -func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router { +func (rtr *Router) AddRoute(path string, h sdk.Handler) sdk.Router { if !isAlphaNumeric(path) { panic("route expressions can only contain alphanumeric characters") } @@ -38,6 +36,6 @@ func (rtr *router) AddRoute(path string, h sdk.Handler) sdk.Router { // Route returns a handler for a given route path. // // TODO: Handle expressive matches. -func (rtr *router) Route(path string) sdk.Handler { +func (rtr *Router) Route(path string) sdk.Handler { return rtr.routes[path] }