aboutsummaryrefslogtreecommitdiff
path: root/rpc/middleware.go
diff options
context:
space:
mode:
authorAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-05-28 16:53:20 +0300
committerAlexander Kiryukhin <a.kiryukhin@mail.ru>2022-05-28 16:53:20 +0300
commitf304a07a8cfe67b2a65f95f27eb10a9b854c4ef8 (patch)
tree9e6a7e9ea6b8d600cccac5a5d50f3232d631d073 /rpc/middleware.go
parent281eda83c9f4bcb06318444df3574df0840205fa (diff)
Improved middlewares
Diffstat (limited to 'rpc/middleware.go')
-rw-r--r--rpc/middleware.go21
1 files changed, 0 insertions, 21 deletions
diff --git a/rpc/middleware.go b/rpc/middleware.go
index cd99823..3887109 100644
--- a/rpc/middleware.go
+++ b/rpc/middleware.go
@@ -19,25 +19,4 @@
package rpc
-import (
- "context"
- "strings"
- "time"
-)
-
type Middleware func(handler RpcHandler) RpcHandler
-
-type RpcHandler func(ctx context.Context, req *RpcRequest) *RpcResponse
-
-func LoggerMiddleware(logger Logger) Middleware {
- return func(handler RpcHandler) RpcHandler {
- return func(ctx context.Context, req *RpcRequest) *RpcResponse {
- t1 := time.Now().UnixMicro()
- resp := handler(ctx, req)
- t2 := time.Now().UnixMicro()
- args := strings.ReplaceAll(string(req.Params), "\n", "")
- logger.Logf("rpc call=%s, args=%s, take=%dμs", req.Method, args, (t2 - t1))
- return resp
- }
- }
-}