generated from ipfs/ipfs-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 98
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(gateway): improve GO API interface, remove Writable API #145
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -5,33 +5,39 @@ import ( | |
"net/http" | ||
"sort" | ||
|
||
coreiface "github.com/ipfs/interface-go-ipfs-core" | ||
path "github.com/ipfs/interface-go-ipfs-core/path" | ||
cid "github.com/ipfs/go-cid" | ||
"github.com/ipfs/go-libipfs/blocks" | ||
"github.com/ipfs/go-libipfs/files" | ||
iface "github.com/ipfs/interface-go-ipfs-core" | ||
"github.com/ipfs/interface-go-ipfs-core/path" | ||
) | ||
|
||
// Config is the configuration that will be applied when creating a new gateway | ||
// handler. | ||
// Config is the configuration used when creating a new gateway handler. | ||
type Config struct { | ||
Headers map[string][]string | ||
Writable bool | ||
Headers map[string][]string | ||
} | ||
|
||
// NodeAPI defines the minimal set of API services required by a gateway handler | ||
type NodeAPI interface { | ||
// Unixfs returns an implementation of Unixfs API | ||
Unixfs() coreiface.UnixfsAPI | ||
// API defines the minimal set of API services required for a gateway handler. | ||
type API interface { | ||
// GetUnixFsNode returns a read-only handle to a file tree referenced by a path. | ||
GetUnixFsNode(context.Context, path.Resolved) (files.Node, error) | ||
|
||
// Block returns an implementation of Block API | ||
Block() coreiface.BlockAPI | ||
// LsUnixFsDir returns the list of links in a directory. | ||
LsUnixFsDir(context.Context, path.Resolved) (<-chan iface.DirEntry, error) | ||
|
||
// Dag returns an implementation of Dag API | ||
Dag() coreiface.APIDagService | ||
// GetBlock return a block from a certain CID. | ||
GetBlock(context.Context, cid.Cid) (blocks.Block, error) | ||
|
||
// Routing returns an implementation of Routing API. | ||
// Used for returning signed IPNS records, see IPIP-0328 | ||
Routing() coreiface.RoutingAPI | ||
// GetIPNSRecord retrieves the best IPNS record for a given CID (libp2p-key) | ||
// from the routing system. | ||
GetIPNSRecord(context.Context, cid.Cid) ([]byte, error) | ||
|
||
// ResolvePath resolves the path using Unixfs resolver | ||
// IsCached returns whether or not the path exists locally. | ||
IsCached(context.Context, path.Path) bool | ||
|
||
// ResolvePath resolves the path using UnixFS resolver. If the path does not | ||
// exist due to a missing link, it should return an error of type: | ||
// https://pkg.go.dev/github.com/ipfs/[email protected]/resolver#ErrNoLink | ||
ResolvePath(context.Context, path.Path) (path.Resolved, error) | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: something like
IPFSBackend
would be more descriptive, but can be changed later, won't block on this one thing (this interface will most likely get revamp in near future anyway)