mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-26 12:57:44 +08:00
coreapi: Global options for api constructor
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com> This commit was moved from ipfs/interface-go-ipfs-core@84509e3878 This commit was moved from ipfs/boxo@3d132ddab1
This commit is contained in:
parent
bee62f1823
commit
f24ab99f72
32
core/coreiface/options/global.go
Normal file
32
core/coreiface/options/global.go
Normal file
@ -0,0 +1,32 @@
|
||||
package options
|
||||
|
||||
type ApiSettings struct {
|
||||
Offline bool
|
||||
}
|
||||
|
||||
type ApiOption func(*ApiSettings) error
|
||||
|
||||
func ApiOptions(opts ...ApiOption) (*ApiSettings, error) {
|
||||
options := &ApiSettings{
|
||||
Offline: false,
|
||||
}
|
||||
|
||||
for _, opt := range opts {
|
||||
err := opt(options)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
return options, nil
|
||||
}
|
||||
|
||||
type apiOpts struct{}
|
||||
|
||||
var Api dagOpts
|
||||
|
||||
func (dagOpts) Offline(offline bool) ApiOption {
|
||||
return func(settings *ApiSettings) error {
|
||||
settings.Offline = offline
|
||||
return nil
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user