Skip to content

Commit

Permalink
Clean up package comment references.
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Dec 10, 2022
1 parent 542dad0 commit d905ac9
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions doc.go
Expand Up @@ -8,10 +8,9 @@ defined by http://www.jsonrpc.org/specification.
The *Server type implements a JSON-RPC server. A server communicates with a
client over a channel.Channel, and dispatches client requests to user-defined
method handlers. Handlers satisfy the jrpc2.Handler interface by exporting a
Handle method with this signature:
method handlers. Method handlers are functions with this signature:
Handle(ctx Context.Context, req *jrpc2.Request) (any, error)
func(ctx Context.Context, req *jrpc2.Request) (any, error)
A server finds the handler for a request by looking up its method name in a
jrpc2.Assigner provided when the server is set up. A Handler can decode the
Expand All @@ -26,8 +25,8 @@ request parameters using the UnmarshalParams method on the request:
}
The handler package makes it easier to use functions that do not have this
exact type signature as handlers, by using reflection to lift functions into
the Handler interface. For example, suppose we want to export this Add function:
exact type signature as handlers, using reflection to wrap them in a Handler
function. For example, suppose we want to export this Add function:
// Add returns the sum of a slice of integers.
func Add(ctx context.Context, values []int) int {
Expand All @@ -38,8 +37,7 @@ the Handler interface. For example, suppose we want to export this Add function
return sum
}
To convert Add to a handler, call handler.New, which wraps its argument in a a
handler.Func, which satisfies the jrpc2.Handler interface:
To convert Add to a handler, call handler.New, which returns a handler.Func:
h := handler.New(Add) // h is now a handler.Func that calls Add
Expand Down

0 comments on commit d905ac9

Please sign in to comment.