WIP jstreamrpc: use new jstream decoding method names
This commit is contained in:
parent
f47e8215eb
commit
131ad8a718
@ -40,20 +40,20 @@ const (
|
|||||||
func unmarshalBody(i interface{}, el jstream.Element) error {
|
func unmarshalBody(i interface{}, el jstream.Element) error {
|
||||||
switch iT := i.(type) {
|
switch iT := i.(type) {
|
||||||
case func(*jstream.StreamReader) error:
|
case func(*jstream.StreamReader) error:
|
||||||
stream, err := el.Stream()
|
stream, err := el.DecodeStream()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return iT(stream)
|
return iT(stream)
|
||||||
case *io.Reader:
|
case *io.Reader:
|
||||||
ioR, err := el.Bytes()
|
ioR, err := el.DecodeBytes()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
*iT = ioR
|
*iT = ioR
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return el.Value(i)
|
return el.DecodeValue(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func HandleCall(
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
var head reqHead
|
var head reqHead
|
||||||
if err := r.Next().Value(&head); err != nil {
|
if err := r.Next().DecodeValue(&head); err != nil {
|
||||||
return err
|
return err
|
||||||
} else if head.Method == "" {
|
} else if head.Method == "" {
|
||||||
return errors.New("request head missing 'method' field")
|
return errors.New("request head missing 'method' field")
|
||||||
@ -118,11 +118,6 @@ func HandleCall(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO to reduce chance of user error maybe Discard should discard any
|
|
||||||
// remaining data on the Element, not on Elements which haven't been read
|
|
||||||
// from yet. Then it could always be called on the request body at this
|
|
||||||
// point.
|
|
||||||
|
|
||||||
// Reading the tail (and maybe discarding the body) should only be done once
|
// Reading the tail (and maybe discarding the body) should only be done once
|
||||||
// marshalBody has finished
|
// marshalBody has finished
|
||||||
if !didReadBody {
|
if !didReadBody {
|
||||||
|
Loading…
Reference in New Issue
Block a user