src/Library/NetPro.StackExchange.Redis/StackExchange.Redis.Extensions.AspNetCore/Midllewares/RedisInformationMiddleware.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using StackExchange.Redis.Extensions.Core.Abstractions;
using System.Linq;
using System.Text.Json;
using System.Threading.Tasks;
namespace StackExchange.Redis.Extensions.AspNetCore.Midllewares
{
internal class RedisInformationMiddleware
{
private readonly ILogger<RedisInformationMiddleware> logger;
private readonly RequestDelegate next;
private readonly IRedisCacheConnectionPoolManager connectionPoolManager;
private readonly IRedisDatabase redisDatabase;
private readonly RedisMiddlewareAccessOptions options;
public RedisInformationMiddleware(
RequestDelegate next,
RedisMiddlewareAccessOptions options,
ILogger<RedisInformationMiddleware> logger,
IRedisCacheConnectionPoolManager connectionPoolManager,
IRedisDatabase redisDatabase)
{
this.next = next;
this.options = options;
this.logger = logger;
this.connectionPoolManager = connectionPoolManager;
this.redisDatabase = redisDatabase;
}
public async Task Invoke(HttpContext context)
{
logger.LogTrace("{0} --> Handling request: {1}", nameof(RedisInformationMiddleware), context.Request.Path);
if (context.Request.Method == "GET" && context.Request.Path == "/redis/connectionInfo")
{
if (!IsClientAllowed(context))
{
await next.Invoke(context);
return;
}
var data = connectionPoolManager.GetConnectionInformations();
await JsonSerializer.SerializeAsync(context.Response.Body, data);
return;
}
if (context.Request.Method == "GET" && context.Request.Path == "/redis/info")
{
if (!IsClientAllowed(context))
{
await next.Invoke(context);
return;
}
var data = await redisDatabase.GetInfoAsync();
后面还有 23 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。