diff options
author | Lewis Marshall <lewis@lmars.net> | 2017-04-07 06:22:22 +0800 |
---|---|---|
committer | Felix Lange <fjl@users.noreply.github.com> | 2017-04-07 06:22:22 +0800 |
commit | 71fdaa42386173da7bfa13f1728c394aeeb4eb01 (patch) | |
tree | 364a169f650982d3b2880c95e40e2c91cb27c86e /cmd/swarm/list.go | |
parent | 9aca9e6deb243b87cc75325be593a3b0c2f0a113 (diff) | |
download | go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.gz go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.bz2 go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.lz go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.xz go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.tar.zst go-tangerine-71fdaa42386173da7bfa13f1728c394aeeb4eb01.zip |
swarm/api: refactor and improve HTTP API (#3773)
This PR deprecates the file related RPC calls in favour of an improved HTTP API.
The main aim is to expose a simple to use API which can be consumed by thin
clients (e.g. curl and HTML forms) without the need for complex logic (e.g.
manipulating prefix trie manifests).
Diffstat (limited to 'cmd/swarm/list.go')
-rw-r--r-- | cmd/swarm/list.go | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/cmd/swarm/list.go b/cmd/swarm/list.go index 3a68fef03..06d3883cf 100644 --- a/cmd/swarm/list.go +++ b/cmd/swarm/list.go @@ -44,7 +44,7 @@ func list(ctx *cli.Context) { bzzapi := strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/") client := swarm.NewClient(bzzapi) - entries, err := client.ManifestFileList(manifest, prefix) + list, err := client.List(manifest, prefix) if err != nil { utils.Fatalf("Failed to generate file and directory list: %s", err) } @@ -52,7 +52,10 @@ func list(ctx *cli.Context) { w := tabwriter.NewWriter(os.Stdout, 1, 2, 2, ' ', 0) defer w.Flush() fmt.Fprintln(w, "HASH\tCONTENT TYPE\tPATH") - for _, entry := range entries { + for _, prefix := range list.CommonPrefixes { + fmt.Fprintf(w, "%s\t%s\t%s\n", "", "DIR", prefix) + } + for _, entry := range list.Entries { fmt.Fprintf(w, "%s\t%s\t%s\n", entry.Hash, entry.ContentType, entry.Path) } } |