mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-26 23:53:19 +08:00
NewRequest() - export OptMap type
This commit is contained in:
@ -15,7 +15,7 @@ import (
|
|||||||
u "github.com/jbenet/go-ipfs/util"
|
u "github.com/jbenet/go-ipfs/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
type optMap map[string]interface{}
|
type OptMap map[string]interface{}
|
||||||
|
|
||||||
type Context struct {
|
type Context struct {
|
||||||
// this Context is temporary. Will be replaced soon, as we get
|
// this Context is temporary. Will be replaced soon, as we get
|
||||||
@ -68,9 +68,9 @@ func (c *Context) NodeWithoutConstructing() *core.IpfsNode {
|
|||||||
type Request interface {
|
type Request interface {
|
||||||
Path() []string
|
Path() []string
|
||||||
Option(name string) *OptionValue
|
Option(name string) *OptionValue
|
||||||
Options() optMap
|
Options() OptMap
|
||||||
SetOption(name string, val interface{})
|
SetOption(name string, val interface{})
|
||||||
SetOptions(opts map[string]interface{}) error
|
SetOptions(opts OptMap) error
|
||||||
Arguments() []string
|
Arguments() []string
|
||||||
SetArguments([]string)
|
SetArguments([]string)
|
||||||
Files() files.File
|
Files() files.File
|
||||||
@ -86,7 +86,7 @@ type Request interface {
|
|||||||
|
|
||||||
type request struct {
|
type request struct {
|
||||||
path []string
|
path []string
|
||||||
options optMap
|
options OptMap
|
||||||
arguments []string
|
arguments []string
|
||||||
files files.File
|
files files.File
|
||||||
cmd *Command
|
cmd *Command
|
||||||
@ -122,8 +122,8 @@ func (r *request) Option(name string) *OptionValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Options returns a copy of the option map
|
// Options returns a copy of the option map
|
||||||
func (r *request) Options() optMap {
|
func (r *request) Options() OptMap {
|
||||||
output := make(optMap)
|
output := make(OptMap)
|
||||||
for k, v := range r.options {
|
for k, v := range r.options {
|
||||||
output[k] = v
|
output[k] = v
|
||||||
}
|
}
|
||||||
@ -151,7 +151,7 @@ func (r *request) SetOption(name string, val interface{}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetOptions sets the option values, unsetting any values that were previously set
|
// SetOptions sets the option values, unsetting any values that were previously set
|
||||||
func (r *request) SetOptions(opts map[string]interface{}) error {
|
func (r *request) SetOptions(opts OptMap) error {
|
||||||
r.options = opts
|
r.options = opts
|
||||||
return r.ConvertOptions()
|
return r.ConvertOptions()
|
||||||
}
|
}
|
||||||
@ -273,12 +273,12 @@ func NewEmptyRequest() (Request, error) {
|
|||||||
|
|
||||||
// NewRequest returns a request initialized with given arguments
|
// NewRequest returns a request initialized with given arguments
|
||||||
// An non-nil error will be returned if the provided option values are invalid
|
// An non-nil error will be returned if the provided option values are invalid
|
||||||
func NewRequest(path []string, opts optMap, args []string, file files.File, cmd *Command, optDefs map[string]Option) (Request, error) {
|
func NewRequest(path []string, opts OptMap, args []string, file files.File, cmd *Command, optDefs map[string]Option) (Request, error) {
|
||||||
if path == nil {
|
if path == nil {
|
||||||
path = make([]string, 0)
|
path = make([]string, 0)
|
||||||
}
|
}
|
||||||
if opts == nil {
|
if opts == nil {
|
||||||
opts = make(map[string]interface{})
|
opts = make(OptMap)
|
||||||
}
|
}
|
||||||
if args == nil {
|
if args == nil {
|
||||||
args = make([]string, 0)
|
args = make([]string, 0)
|
||||||
|
Reference in New Issue
Block a user