From f304a07a8cfe67b2a65f95f27eb10a9b854c4ef8 Mon Sep 17 00:00:00 2001 From: Alexander Kiryukhin Date: Sat, 28 May 2022 16:53:20 +0300 Subject: Improved middlewares --- rpc/middleware.go | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'rpc/middleware.go') 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 - } - } -} -- cgit v1.2.3