1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-24 05:59:55 +08:00

commands: Changed Marshaler to return a io.Reader instead of a []byte

core/commands: Refactored command marshalers
This commit is contained in:
Matt Bell
2014-12-16 04:31:13 -08:00
parent 0395a7af1e
commit fd40702f73
19 changed files with 136 additions and 85 deletions

View File

@ -2,7 +2,9 @@ package commands
import (
"bytes"
"io"
"io/ioutil"
"strings"
"time"
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
@ -123,9 +125,9 @@ It reads from stdin, and <key> is a base58 encoded multihash.
},
Type: &Block{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) ([]byte, error) {
cmds.Text: func(res cmds.Response) (io.Reader, error) {
block := res.Output().(*Block)
return []byte(block.Key + "\n"), nil
return strings.NewReader(block.Key + "\n"), nil
},
},
}