diff options
author | Janoš Guljaš <janos@users.noreply.github.com> | 2017-12-19 16:49:30 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-12-19 16:49:30 +0800 |
commit | c786f75389121c29d4380c53a013759254457776 (patch) | |
tree | dc43ce4aa2371c934c364c5c22e0f7fd7b7d45ae /swarm/api/uri.go | |
parent | 7f9d94fe9aacd4122f12f1fa75223ac9f8c9380e (diff) | |
download | dexon-c786f75389121c29d4380c53a013759254457776.tar dexon-c786f75389121c29d4380c53a013759254457776.tar.gz dexon-c786f75389121c29d4380c53a013759254457776.tar.bz2 dexon-c786f75389121c29d4380c53a013759254457776.tar.lz dexon-c786f75389121c29d4380c53a013759254457776.tar.xz dexon-c786f75389121c29d4380c53a013759254457776.tar.zst dexon-c786f75389121c29d4380c53a013759254457776.zip |
swarm: bzz-list, bzz-raw and bzz-immutable schemes (#15667)
* swarm/api: url scheme bzz-list for getting list of files from manifest
Replace query parameter list=true for listing all files contained
in a swarm manifest with a new URL scheme bzz-list.
* swarm: replaace bzzr and bzzi schemes with bzz-raw and bzz-immutable
New URI Shemes are added and old ones are deprecated, but not removed.
Old Schemes bzzr and bzzi are functional for backward compatibility.
* swarm/api: completely remove bzzr and bzzi schemes
Remove old schemes in favour of bzz-raw and
bzz-immutable.
* swarm/api: revert "completely remove bzzr and bzzi schemes"
Keep bzzr and bzzi schemes for backward compatibility. At least
until 0.3 swarm release.
Diffstat (limited to 'swarm/api/uri.go')
-rw-r--r-- | swarm/api/uri.go | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/swarm/api/uri.go b/swarm/api/uri.go index caed4212d..af1dc7445 100644 --- a/swarm/api/uri.go +++ b/swarm/api/uri.go @@ -26,7 +26,13 @@ import ( type URI struct { // Scheme has one of the following values: // - // * bzz - an entry in a swarm manifest + // * bzz - an entry in a swarm manifest + // * bzz-raw - raw swarm content + // * bzz-immutable - immutable URI of an entry in a swarm manifest + // (address is not resolved) + // * bzz-list - list of all files contained in a swarm manifest + // + // Deprecated Schemes: // * bzzr - raw swarm content // * bzzi - immutable URI of an entry in a swarm manifest // (address is not resolved) @@ -50,7 +56,8 @@ type URI struct { // * <scheme>://<addr> // * <scheme>://<addr>/<path> // -// with scheme one of bzz, bzzr or bzzi +// with scheme one of bzz, bzz-raw, bzz-immutable or bzz-list +// or deprecated ones bzzr and bzzi func Parse(rawuri string) (*URI, error) { u, err := url.Parse(rawuri) if err != nil { @@ -60,7 +67,7 @@ func Parse(rawuri string) (*URI, error) { // check the scheme is valid switch uri.Scheme { - case "bzz", "bzzi", "bzzr": + case "bzz", "bzz-raw", "bzz-immutable", "bzz-list", "bzzr", "bzzi": default: return nil, fmt.Errorf("unknown scheme %q", u.Scheme) } @@ -84,10 +91,22 @@ func Parse(rawuri string) (*URI, error) { } func (u *URI) Raw() bool { - return u.Scheme == "bzzr" + return u.Scheme == "bzz-raw" } func (u *URI) Immutable() bool { + return u.Scheme == "bzz-immutable" +} + +func (u *URI) List() bool { + return u.Scheme == "bzz-list" +} + +func (u *URI) DeprecatedRaw() bool { + return u.Scheme == "bzzr" +} + +func (u *URI) DeprecatedImmutable() bool { return u.Scheme == "bzzi" } |