core/types: fix json encoding for Request

This commit is contained in:
islishude 2024-09-12 16:02:51 +08:00
parent ec69830b6f
commit 9680a5f61e

View file

@ -18,6 +18,7 @@ package types
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
@ -94,6 +95,11 @@ func (r *Request) encode(w *bytes.Buffer) error {
return r.inner.encode(w)
}
// MarshalJSON marshals as JSON.
func (r *Request) MarshalJSON() ([]byte, error) {
return json.Marshal(r.inner)
}
// MarshalBinary returns the canonical encoding of the request.
func (r *Request) MarshalBinary() ([]byte, error) {
var buf bytes.Buffer