mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-02 03:28:25 +08:00
commands: Changed option accessor API (Request#Option now returns an OptionValue)
This commit is contained in:

committed by
Juan Batiz-Benet

parent
20591c7e64
commit
3e507f7c9f
@ -108,18 +108,22 @@ func (r *response) Marshal() ([]byte, error) {
|
||||
return []byte{}, nil
|
||||
}
|
||||
|
||||
enc, found := r.req.Option(EncShort)
|
||||
encStr, ok := enc.(string)
|
||||
if !found || !ok || encStr == "" {
|
||||
fmt.Println(r.req, r.req.Option(EncShort))
|
||||
if !r.req.Option(EncShort).Found() {
|
||||
return nil, fmt.Errorf("No encoding type was specified")
|
||||
}
|
||||
encType := EncodingType(strings.ToLower(encStr))
|
||||
enc, err := r.req.Option(EncShort).String()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
encType := EncodingType(strings.ToLower(enc))
|
||||
|
||||
var marshaller Marshaller
|
||||
if r.req.Command() != nil && r.req.Command().Marshallers != nil {
|
||||
marshaller = r.req.Command().Marshallers[encType]
|
||||
}
|
||||
if marshaller == nil {
|
||||
var ok bool
|
||||
marshaller, ok = marshallers[encType]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("No marshaller found for encoding type '%s'", enc)
|
||||
|
Reference in New Issue
Block a user