generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(gateway): decouple read, write, and offline Node APIs
- Loading branch information
Showing
9 changed files
with
93 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package gateway | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
cid "github.com/ipfs/go-cid" | ||
ipld "github.com/ipfs/go-ipld-format" | ||
"github.com/ipfs/go-libipfs/files" | ||
iface "github.com/ipfs/interface-go-ipfs-core" | ||
options "github.com/ipfs/interface-go-ipfs-core/options" | ||
"github.com/ipfs/interface-go-ipfs-core/path" | ||
) | ||
|
||
type ReaderDagAPI interface { | ||
Get(context.Context, cid.Cid) (ipld.Node, error) | ||
} | ||
|
||
type ReaderBlockAPI interface { | ||
Get(context.Context, path.Path) (io.Reader, error) | ||
Stat(context.Context, path.Path) (iface.BlockStat, error) | ||
} | ||
|
||
type ReaderRoutingAPI interface { | ||
Get(context.Context, string) ([]byte, error) | ||
} | ||
|
||
type ReaderUnixFsAPI interface { | ||
Get(context.Context, path.Path) (files.Node, error) | ||
Ls(context.Context, path.Path, ...options.UnixfsLsOption) (<-chan iface.DirEntry, error) | ||
} | ||
|
||
// ReaderAPI defines the minimal set of API services required for a read-only | ||
// gateway handler. These are, for the most part, subsets of the core interface. | ||
type ReaderAPI interface { | ||
// UnixFs returns an implementation of Readable UnixFs API. | ||
UnixFs() ReaderUnixFsAPI | ||
|
||
// Block returns an implementation of Readable Block API. | ||
Block() ReaderBlockAPI | ||
|
||
// Dag returns an implementation of Readable Dag API. | ||
Dag() ReaderDagAPI | ||
|
||
// Routing returns an implementation of Readable Routing API. | ||
// Used for returning signed IPNS records, see IPIP-0328 | ||
Routing() ReaderRoutingAPI | ||
|
||
// ResolvePath resolves the path using UnixFS resolver | ||
ResolvePath(context.Context, path.Path) (path.Resolved, error) | ||
} | ||
|
||
type OfflineBlockAPI interface { | ||
Stat(context.Context, path.Path) (iface.BlockStat, error) | ||
} | ||
|
||
// OfflineAPI defines the API services required to work in offline mode. This | ||
// are used for caching handling when 'Cache-Control: only-if-cached'. | ||
type OfflineAPI interface { | ||
Block() OfflineBlockAPI | ||
} | ||
|
||
type WriterUnixFsAPI interface { | ||
Add(context.Context, files.Node, ...options.UnixfsAddOption) (path.Resolved, error) | ||
} | ||
|
||
// WriterAPI defines the API services required to work with a writable gateway. | ||
// These are full services from the core interface API. This is EXPERIMENTAL | ||
// and CAN change in the future. | ||
type WriterAPI interface { | ||
UnixFs() WriterUnixFsAPI | ||
Dag() iface.APIDagService | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters