mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-16 04:04:56 +02:00
initial commit
This commit is contained in:
commit
c04eec1600
8 changed files with 1285 additions and 0 deletions
20
call_opt.go
Normal file
20
call_opt.go
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
package jsonrpc2
|
||||
|
||||
// CallOption is an option that can be provided to (*Conn).Call to
|
||||
// configure custom behavior. See Meta.
|
||||
type CallOption interface {
|
||||
apply(r *Request) error
|
||||
}
|
||||
|
||||
type callOptionFunc func(r *Request) error
|
||||
|
||||
func (c callOptionFunc) apply(r *Request) error { return c(r) }
|
||||
|
||||
// Meta returns a call option which attaches the given meta object to
|
||||
// the JSON-RPC 2.0 request (this is a Sourcegraph extension to JSON
|
||||
// RPC 2.0 for carrying metadata).
|
||||
func Meta(meta interface{}) CallOption {
|
||||
return callOptionFunc(func(r *Request) error {
|
||||
return r.SetMeta(meta)
|
||||
})
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue