mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-03 07:18:12 +08:00
33 lines
506 B
Go
33 lines
506 B
Go
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
|
|
}
|
|
}
|