diff options
author | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-05-28 16:53:20 +0300 |
---|---|---|
committer | Alexander Kiryukhin <a.kiryukhin@mail.ru> | 2022-05-28 16:53:20 +0300 |
commit | f304a07a8cfe67b2a65f95f27eb10a9b854c4ef8 (patch) | |
tree | 9e6a7e9ea6b8d600cccac5a5d50f3232d631d073 /rpc/middleware.go | |
parent | 281eda83c9f4bcb06318444df3574df0840205fa (diff) |
Improved middlewares
Diffstat (limited to 'rpc/middleware.go')
-rw-r--r-- | rpc/middleware.go | 21 |
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 - } - } -} |