-
Notifications
You must be signed in to change notification settings - Fork 331
Expand file tree
/
Copy pathCompressionOptions.cs
More file actions
46 lines (39 loc) · 1.33 KB
/
CompressionOptions.cs
File metadata and controls
46 lines (39 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
using System.Text.Json.Serialization;
namespace Azure.DataApiBuilder.Config.ObjectModel;
/// <summary>
/// Configuration options for HTTP response compression.
/// </summary>
public record CompressionOptions
{
/// <summary>
/// Default compression level is Optimal.
/// </summary>
public const CompressionLevel DEFAULT_LEVEL = CompressionLevel.Optimal;
/// <summary>
/// The compression level to use for HTTP response compression.
/// </summary>
[JsonPropertyName("level")]
public CompressionLevel Level { get; init; } = DEFAULT_LEVEL;
/// <summary>
/// Flag which informs CLI and JSON serializer whether to write Level
/// property and value to the runtime config file.
/// </summary>
[JsonIgnore(Condition = JsonIgnoreCondition.Always)]
public bool UserProvidedLevel { get; init; } = false;
[JsonConstructor]
public CompressionOptions(CompressionLevel Level = DEFAULT_LEVEL)
{
this.Level = Level;
this.UserProvidedLevel = true;
}
/// <summary>
/// Default parameterless constructor for cases where no compression level is specified.
/// </summary>
public CompressionOptions()
{
this.Level = DEFAULT_LEVEL;
this.UserProvidedLevel = false;
}
}