From f24ab99f72cfd21bd1db9c781da52ea0e9ca0945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 6 Dec 2018 10:47:51 +0100 Subject: [PATCH] coreapi: Global options for api constructor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit License: MIT Signed-off-by: Ɓukasz Magiera This commit was moved from ipfs/interface-go-ipfs-core@84509e38781da3257c7a82d09483b4c7d9188a10 This commit was moved from ipfs/boxo@3d132ddab18ee64dc731918e08fd4548d1b335dc --- core/coreiface/options/global.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 core/coreiface/options/global.go diff --git a/core/coreiface/options/global.go b/core/coreiface/options/global.go new file mode 100644 index 000000000..f43965229 --- /dev/null +++ b/core/coreiface/options/global.go @@ -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 + } +}