File tree Expand file tree Collapse file tree 3 files changed +26
-3
lines changed
Expand file tree Collapse file tree 3 files changed +26
-3
lines changed Original file line number Diff line number Diff line change 11using IUTest ;
22using RedisUI ;
3+ using StackExchange . Redis ;
34
45var builder = WebApplication . CreateBuilder ( args ) ;
56
2223
2324app . UseRouting ( ) ;
2425
26+ ConfigurationOptions options = new ConfigurationOptions
27+ {
28+ EndPoints = { { "localhost" , 6379 } } ,
29+ } ;
30+
2531app . UseRedisUI ( new RedisUISettings
2632{
27- AuthorizationFilter = new FooAuthorizationFilter ( app . Environment . IsDevelopment ( ) )
33+ AuthorizationFilter = new FooAuthorizationFilter ( app . Environment . IsDevelopment ( ) ) ,
34+ //ConfigurationOptions = options
2835} ) ;
2936
3037app . UseAuthorization ( ) ;
Original file line number Diff line number Diff line change 1- namespace RedisUI
1+ using StackExchange . Redis ;
2+
3+ namespace RedisUI
24{
35 public class RedisUISettings
46 {
@@ -7,6 +9,11 @@ public class RedisUISettings
79 /// </summary>
810 public string ConnectionString { get ; set ; } = "localhost" ;
911
12+ /// <summary>
13+ /// Gets or sets the ConfigurationOptions instance.
14+ /// </summary>
15+ public ConfigurationOptions ConfigurationOptions { get ; set ; }
16+
1017 /// <summary>
1118 /// Gets or sets the path for the Redis server.
1219 /// </summary>
Original file line number Diff line number Diff line change @@ -37,7 +37,16 @@ public async Task InvokeAsync(HttpContext context)
3737 var db = context . Request . Query [ "db" ] . ToString ( ) ;
3838 int currentDb = string . IsNullOrEmpty ( db ) ? 0 : int . Parse ( db ) ;
3939
40- IDatabase redisDb = ConnectionMultiplexer . Connect ( _settings . ConnectionString ) . GetDatabase ( currentDb ) ;
40+ IDatabase redisDb ;
41+
42+ if ( _settings . ConfigurationOptions != null )
43+ {
44+ redisDb = ConnectionMultiplexer . Connect ( _settings . ConfigurationOptions ) . GetDatabase ( currentDb ) ;
45+ }
46+ else
47+ {
48+ redisDb = ConnectionMultiplexer . Connect ( _settings . ConnectionString ) . GetDatabase ( currentDb ) ;
49+ }
4150
4251 var dbSize = await redisDb . ExecuteAsync ( "DBSIZE" ) ;
4352
You can’t perform that action at this time.
0 commit comments