-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/baseserver, */rest: allow baseserver to choose which handlers to use #207
cmd/baseserver, */rest: allow baseserver to choose which handlers to use #207
Conversation
Make handlers easily configurable to use in cmd/baseserver/main.go. This way client users can trivially change what functionality they'd like. It involves moving ServeCmd out of client/rest to */main.go and lets client/rest become a bazaar for available mux.Router registrars. Updates #200
/cc @ethanfrey |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice work. I like it.
Just the comment about moving the bulk of ServeCmd back into client/rest and only passing in the list of route registration functions into the server from main.go.
// GET: /keys/{name} | ||
// POST, PUT: /keys/{name} | ||
// DELETE: /keys/{name} | ||
func (k *Keys) RegisterAllCRUD(r *mux.Router) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice job pulling out these regsiter functions.
func serve(cmd *cobra.Command, args []string) error { | ||
router := mux.NewRouter() | ||
|
||
routeRegistrars := []func(*mux.Router) error{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the flexibility of this function very much. But still don't want to have to add all this code in every app. The only thing that changes between apps is routeRegistrars.
For DRY, I would prefer adding some global way to set the routeRegistrars
from main.go (calling a function, directly setting a public variable, ...) but have the rest of this file back in client/rest
|
||
// RegisterAll is a convenience function to | ||
// register all the handlers in this package. | ||
func RegisterAll(r *mux.Router) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A bit verbose having the three functions, but very, very awesome for enabling remixing in the different applications.
I like it.
Okay, maybe serve in main.go is the best approach, since there is little logic there, and it lets each app create it's own server stack - set up https, middleware, etc.. as needed. I am convinced. |
Thanks for the review and merge @ethanfrey! |
fix: Correctly compute post-clawback end time.
* Add proto for Clawback Vesting Account * Change field to int * Change field to int64 * add place holder for clawback * add handler and basic msgs methods * add clawback vesting account logic * improvements * fix: Dev/clawback test debug (#198) * add tests * add clawback before starttime test * clean imports * Printlns for the clawback testing * Fix tests and logic * Fix the gas exhaustion vuln * Remove printlns * Delete extraneous account set * chore: add table driven test cases to clawback (#199) * add table driven tests * Modify test cases * More detail in error message * Update x/auth/vesting/types/vesting_account_test.go * Update x/auth/vesting/types/vesting_account_test.go Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: Dev Ojha <dojha@berkeley.edu> Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> * fix: cherry pick agoric's cosmos sdk#207 (#203) * cherry pick compute endtime fix * Merge branch 'osmosis-main' into mattverse/clawback Co-authored-by: mattverse <mattpark1028@gmail.com> Co-authored-by: Matt, Park <45252226+mattverse@users.noreply.github.com> * feat: add clawback cli and tests (#207) * add clawback cli and tests * Update x/auth/vesting/client/cli/tx.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update x/auth/vesting/client/cli/tx.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Update x/auth/vesting/client/cli/tx.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * minor fix * Minor fix * Update x/auth/vesting/client/cli/cli_test.go Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> * Change from code review from Alex and Dev Co-authored-by: Dev Ojha <ValarDragon@users.noreply.github.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
Solution: - remove the api changelog
Solution: - remove the api changelog
Solution: - remove the api changelog
Solution: - remove the api changelog
Solution: - remove the api changelog
This reverts commit 56cb96c.
* Revert "Problem: CacheWrapWithTrace api is not used (cosmos#207)" This reverts commit 56cb96c. * resolve * cleanup * fix cyclic dependency * fix test * better equavalence --------- Co-authored-by: HuangYi <huang@crypto.com>
Make handlers easily configurable to use in cmd/baseserver/main.go.
This way client users can trivially change what functionality they'd
like.
It involves moving ServeCmd out of client/rest to */main.go
and lets client/rest become a bazaar for available mux.Router
registrars.
Updates #200