-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from go-zoox/feat/refactor-jsonrpc
feat: refactor jsonrpc
- Loading branch information
Showing
7 changed files
with
55 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jsonrpc | ||
|
||
import ( | ||
"github.com/go-zoox/core-utils/object" | ||
"github.com/go-zoox/tag" | ||
"github.com/go-zoox/tag/datasource" | ||
) | ||
|
||
// Params is a map of params. | ||
type Params map[string]any | ||
|
||
// Bind binds the jsonrpc params into the given struct. | ||
func (p Params) Bind(obj any) error { | ||
return tag.New("json", datasource.NewMapDataSource(p)).Decode(obj) | ||
} | ||
|
||
// Get returns the value of the given key. | ||
func (p Params) Get(key string) any { | ||
return object.Get(p, key) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package jsonrpc | ||
|
||
// Result is a map of result. | ||
type Result map[string]any |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters