mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 20:32:58 +08:00
commands: Added Request#Options so consumers can iterate through provided options
This commit is contained in:

committed by
Juan Batiz-Benet

parent
e8b37acda3
commit
a65c99e71e
@ -13,6 +13,7 @@ type optMap map[string]interface{}
|
|||||||
type Request interface {
|
type Request interface {
|
||||||
Path() []string
|
Path() []string
|
||||||
Option(name string) (interface{}, bool)
|
Option(name string) (interface{}, bool)
|
||||||
|
Options() map[string]interface{}
|
||||||
SetOption(name string, val interface{})
|
SetOption(name string, val interface{})
|
||||||
Arguments() []string
|
Arguments() []string
|
||||||
Stream() io.Reader
|
Stream() io.Reader
|
||||||
@ -39,6 +40,15 @@ func (r *request) Option(name string) (interface{}, bool) {
|
|||||||
return val, err
|
return val, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Options returns a copy of the option map
|
||||||
|
func (r *request) Options() map[string]interface{} {
|
||||||
|
output := make(optMap)
|
||||||
|
for k, v := range r.options {
|
||||||
|
output[k] = v
|
||||||
|
}
|
||||||
|
return output
|
||||||
|
}
|
||||||
|
|
||||||
// SetOption sets the value of the option for given name.
|
// SetOption sets the value of the option for given name.
|
||||||
func (r *request) SetOption(name string, val interface{}) {
|
func (r *request) SetOption(name string, val interface{}) {
|
||||||
r.options[name] = val
|
r.options[name] = val
|
||||||
|
Reference in New Issue
Block a user