Skip to content

Commit

Permalink
[*] Disable Compression option (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoraller authored May 25, 2023
1 parent 261bb51 commit 22402a8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
21 changes: 12 additions & 9 deletions src/EdjCase.JsonRpc.Router/BuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using EdjCase.JsonRpc.Router;
using EdjCase.JsonRpc.Router.Abstractions;
using EdjCase.JsonRpc.Router.Defaults;
Expand Down Expand Up @@ -43,16 +43,22 @@ public static IServiceCollection AddJsonRpc(this IServiceCollection serviceColle
{
throw new ArgumentNullException(nameof(serviceCollection));
}

if (configuration == null)
{
configuration = new RpcServerConfiguration();
}
serviceCollection.AddSingleton(new RpcServicesMarker());
serviceCollection
.TryAddScoped<IRpcInvoker, DefaultRpcInvoker>();
serviceCollection
.TryAddScoped<IRpcParser, DefaultRpcParser>();
serviceCollection
.TryAddScoped<IRpcRequestHandler, RpcRequestHandler>();
serviceCollection
.TryAddScoped<IStreamCompressor, DefaultStreamCompressor>();
.TryAddScoped<IRpcRequestHandler, RpcRequestHandler>();
if (configuration.UseCompression)
{
serviceCollection
.TryAddScoped<IStreamCompressor, DefaultStreamCompressor>();
}
serviceCollection
.TryAddScoped<IRpcResponseSerializer, DefaultRpcResponseSerializer>();
serviceCollection
Expand All @@ -69,10 +75,7 @@ public static IServiceCollection AddJsonRpc(this IServiceCollection serviceColle
.TryAddSingleton<StaticRpcMethodDataAccessor>();
serviceCollection.AddHttpContextAccessor();

if (configuration == null)
{
configuration = new RpcServerConfiguration();
}

return serviceCollection
.AddSingleton(Options.Create(configuration))
.AddRouting()
Expand Down
9 changes: 7 additions & 2 deletions src/EdjCase.JsonRpc.Router/Configuration.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Text.Json;
using EdjCase.JsonRpc.Router.Abstractions;

Expand Down Expand Up @@ -41,7 +41,12 @@ public class RpcServerConfiguration
/// <summary>
/// If specified the router will call the specified method when the invoker has finished.
/// </summary>
public Action<RpcInvokeContext, RpcResponse>? OnInvokeEnd { get; set; }
public Action<RpcInvokeContext, RpcResponse>? OnInvokeEnd { get; set; }

/// <summary>
/// If true will support use Gzip and Deflate compression
/// </summary>
public bool UseCompression { get; set; } = true;
}

public class ExceptionContext
Expand Down

0 comments on commit 22402a8

Please sign in to comment.