Skip to content

Commit 83d405d

Browse files
authored
Add ConfigureHttpJsonOptions for M.A.Htt.Json.JsonOptions
1 parent 07d728b commit 83d405d

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using Microsoft.AspNetCore.Http.Json;
5+
using Microsoft.Extensions.DependencyInjection;
6+
7+
namespace Microsoft.AspNetCore.Http;
8+
9+
/// <summary>
10+
/// Extension methods to configure JSON serialization behavior.
11+
/// </summary>
12+
public static class HttpJsonServiceExtensions
13+
{
14+
/// <summary>
15+
/// Configures options used for reading and writing JSON by route handlers.
16+
/// </summary>
17+
/// <remarks>
18+
/// The options configured here will only affect JSON returned and processed
19+
/// from route handlers, not controllers.
20+
/// </remarks>
21+
/// <param name="services">The <see cref="IServiceCollection" /> to configure options on.</param>
22+
/// <param name="configureOptions">The <see cref="Action{JsonOptions}"/> to configure the
23+
/// <see cref="JsonOptions"/>.</param>
24+
/// <returns>The modified <see cref="IServiceCollection"/>.</returns>
25+
public static IServiceCollection ConfigureHttpJsonOptions(this IServiceCollection services, Action<JsonOptions> configureOptions)
26+
{
27+
services.Configure<JsonOptions>(configureOptions);
28+
return services;
29+
}
30+
}
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
#nullable enable
2+
Microsoft.AspNetCore.Http.HttpJsonServiceExtensions
3+
static Microsoft.AspNetCore.Http.HttpJsonServiceExtensions.ConfigureHttpJsonOptions(this Microsoft.Extensions.DependencyInjection.IServiceCollection! services, System.Action<Microsoft.AspNetCore.Http.Json.JsonOptions!>! configureOptions) -> Microsoft.Extensions.DependencyInjection.IServiceCollection!

0 commit comments

Comments
 (0)