mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
Ensure that SetExtraField cannot be used to overwrite another field
This commit is contained in:
parent
83d34e6888
commit
4e1e529bef
1 changed files with 4 additions and 0 deletions
|
|
@ -179,6 +179,10 @@ func (r *Request) SetMeta(v interface{}) error {
|
|||
// JSON representation of the request, as a way to add arbitrary extensions to
|
||||
// JSON RPC 2.0. If JSON marshaling fails, it returns an error.
|
||||
func (r *Request) SetExtraField(name string, v interface{}) error {
|
||||
switch name {
|
||||
case "id", "jsonrpc", "meta", "method", "params":
|
||||
return fmt.Errorf("invalid extra field %q", name)
|
||||
}
|
||||
r.ExtraFields = append(r.ExtraFields, RequestField{
|
||||
Name: name,
|
||||
Value: v,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue