mirror of
https://github.com/sourcegraph/jsonrpc2.git
synced 2026-06-19 05:30:03 +02:00
Adjust Handler interface and support middleware
This commit is contained in:
parent
c9c77b6bb9
commit
4188fa4438
8 changed files with 127 additions and 46 deletions
6
async.go
6
async.go
|
|
@ -1,7 +1,5 @@
|
|||
package jsonrpc2
|
||||
|
||||
import "context"
|
||||
|
||||
// AsyncHandler wraps a Handler such that each request is handled in its own
|
||||
// goroutine. It is a convenience wrapper.
|
||||
func AsyncHandler(h Handler) Handler {
|
||||
|
|
@ -12,6 +10,6 @@ type asyncHandler struct {
|
|||
Handler
|
||||
}
|
||||
|
||||
func (h asyncHandler) Handle(ctx context.Context, conn *Conn, req *Request) {
|
||||
go h.Handler.Handle(ctx, conn, req)
|
||||
func (h asyncHandler) Handle(conn *Conn, req *Request) {
|
||||
go h.Handler.Handle(conn, req)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue