Skip to content

Commit de3f295

Browse files
committed
Add AddMqttDefaultJsonOptions extension
1 parent 7f9db8e commit de3f295

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Source/Extensions/ServiceCollectionExtensions.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System;
77
using System.Reflection;
88
using System.Runtime.CompilerServices;
9+
using System.Text.Json;
910

1011
// This is needed to make internal classes visible to UnitTesting projects
1112
[assembly: InternalsVisibleTo("MQTTnet.AspNetCore.Routing.Tests, PublicKey=00240000048000009" +
@@ -38,6 +39,13 @@ public static IServiceCollection AddMqttControllers(this IServiceCollection serv
3839
return services;
3940
}
4041

42+
public static IServiceCollection AddMqttDefaultJsonOptions(this IServiceCollection services,
43+
JsonSerializerOptions options)
44+
{
45+
services.AddSingleton(new MqttDefaultJsonOptions(options));
46+
return services;
47+
}
48+
4149
public static void WithAttributeRouting(this MqttServer server, IServiceProvider svcProvider, bool allowUnmatchedRoutes = false)
4250
{
4351
var router = svcProvider.GetRequiredService<MqttRouter>();

0 commit comments

Comments
 (0)