1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-05-21 08:56:37 +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

@ -4,6 +4,7 @@ package commands
import (
"fmt"
"io"
"strings"
"time"
@ -134,11 +135,11 @@ baz
},
Type: &config.Mounts{},
Marshalers: cmds.MarshalerMap{
cmds.Text: func(res cmds.Response) ([]byte, error) {
cmds.Text: func(res cmds.Response) (io.Reader, error) {
v := res.Output().(*config.Mounts)
s := fmt.Sprintf("IPFS mounted at: %s\n", v.IPFS)
s += fmt.Sprintf("IPNS mounted at: %s\n", v.IPNS)
return []byte(s), nil
return strings.NewReader(s), nil
},
},
}