mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
Make Gateway.NoFetch apply to API too
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
6cee21d39a
commit
7efffc3579
@ -560,13 +560,16 @@ func serveHTTPGateway(req *cmds.Request, cctx *oldcmds.Context) (<-chan error, e
|
||||
listeners = append(listeners, gwLis)
|
||||
}
|
||||
|
||||
cmdctx := *cctx
|
||||
cmdctx.Gateway = true
|
||||
|
||||
var opts = []corehttp.ServeOption{
|
||||
corehttp.MetricsCollectionOption("gateway"),
|
||||
corehttp.IPNSHostnameOption(),
|
||||
corehttp.GatewayOption(writable, "/ipfs", "/ipns"),
|
||||
corehttp.VersionOption(),
|
||||
corehttp.CheckVersionOption(),
|
||||
corehttp.CommandsROOption(*cctx),
|
||||
corehttp.CommandsROOption(cmdctx),
|
||||
}
|
||||
|
||||
if cfg.Experimental.P2pHttpProxy {
|
||||
|
||||
@ -9,6 +9,7 @@ import (
|
||||
core "github.com/ipfs/go-ipfs/core"
|
||||
coreapi "github.com/ipfs/go-ipfs/core/coreapi"
|
||||
coreiface "github.com/ipfs/go-ipfs/core/coreapi/interface"
|
||||
options "github.com/ipfs/go-ipfs/core/coreapi/interface/options"
|
||||
loader "github.com/ipfs/go-ipfs/plugin/loader"
|
||||
|
||||
config "gx/ipfs/QmRd5T3VmYoX6jaNoZovFRQcwWHJqHgTVQTs1Qz92ELJ7C/go-ipfs-config"
|
||||
@ -29,6 +30,7 @@ type Context struct {
|
||||
config *config.Config
|
||||
LoadConfig func(path string) (*config.Config, error)
|
||||
|
||||
Gateway bool
|
||||
api coreiface.CoreAPI
|
||||
node *core.IpfsNode
|
||||
ConstructNode func() (*core.IpfsNode, error)
|
||||
@ -68,7 +70,16 @@ func (c *Context) GetAPI() (coreiface.CoreAPI, error) {
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.api, err = coreapi.NewCoreAPI(n)
|
||||
offline := false
|
||||
if c.Gateway {
|
||||
cfg, err := c.GetConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
offline = cfg.Gateway.NoFetch
|
||||
}
|
||||
|
||||
c.api, err = coreapi.NewCoreAPI(n, options.Api.Offline(offline))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user