Skip to content
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

Merged
merged 1 commit into from
Aug 3, 2017
Merged

cmd/baseserver, */rest: allow baseserver to choose which handlers to use #207

merged 1 commit into from
Aug 3, 2017

Conversation

odeke-em
Copy link
Collaborator

@odeke-em odeke-em commented Aug 3, 2017

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

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
@odeke-em
Copy link
Collaborator Author

odeke-em commented Aug 3, 2017

/cc @ethanfrey

Copy link
Contributor

@ethanfrey ethanfrey left a 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 {
Copy link
Contributor

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{
Copy link
Contributor

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 {
Copy link
Contributor

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.

@ethanfrey
Copy link
Contributor

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.

@ethanfrey ethanfrey merged commit 2f22070 into cosmos:unstable Aug 3, 2017
@odeke-em
Copy link
Collaborator Author

odeke-em commented Aug 3, 2017

Thanks for the review and merge @ethanfrey!

mattverse referenced this pull request in mattverse/cosmos-sdk Apr 20, 2022
fix: Correctly compute post-clawback end time.
alexanderbez added a commit that referenced this pull request May 26, 2022
* 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>
yihuang added a commit to yihuang/cosmos-sdk that referenced this pull request Mar 25, 2024
Solution:
- remove the api

changelog
dudong2 referenced this pull request in b-harvest/cosmos-sdk Oct 17, 2024
Solution:
- remove the api

changelog
dudong2 referenced this pull request in b-harvest/cosmos-sdk Oct 30, 2024
Solution:
- remove the api

changelog
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 12, 2024
mmsqe pushed a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 12, 2024
mmsqe added a commit to mmsqe/cosmos-sdk that referenced this pull request Dec 12, 2024
mmsqe added a commit to mmsqe/cosmos-sdk that referenced this pull request Jan 17, 2025
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants