Skip to content

Commit b660270

Browse files
Renames appsetings to mgdprc (#252)
Adds fallback to load mgdprc from appFolder
1 parent 31cf84c commit b660270

File tree

7 files changed

+19
-12
lines changed

7 files changed

+19
-12
lines changed

msgraph-developer-proxy/ProxyConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ public class ProxyConfiguration: IProxyConfiguration {
2121
public IEnumerable<string> WatchProcessNames { get; set; } = new List<string>();
2222
[JsonPropertyName("rate")]
2323
public int Rate { get; set; } = 50;
24-
public string ConfigFile { get; set; } = "appsettings.json";
24+
public string ConfigFile { get; set; } = "mgdprc.json";
2525
}
2626

msgraph-developer-proxy/ProxyEngine.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public ProxyEngine(ProxyConfiguration config, ISet<UrlToWatch> urlsToWatch, Plug
4747

4848
public async Task Run(CancellationToken? cancellationToken) {
4949
if (!_urlsToWatch.Any()) {
50-
_logger.LogInfo("No URLs to watch configured. Please add URLs to watch in the appsettings.json config file.");
50+
_logger.LogInfo("No URLs to watch configured. Please add URLs to watch in the mgdprc.json config file.");
5151
return;
5252
}
5353

msgraph-developer-proxy/ProxyHost.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ internal class ProxyHost {
1717
private Option<int?> _rateOption;
1818

1919
private static bool _configFileResolved = false;
20-
private static string _configFile = "appsettings.json";
20+
private static string _configFile = "mgdprc.json";
2121
public static string ConfigFile {
2222
get {
2323
if (_configFileResolved) {
@@ -45,6 +45,13 @@ public static string ConfigFile {
4545
if (configFile is not null) {
4646
_configFile = configFile;
4747
}
48+
else {
49+
// if there's no config file in the current working folder
50+
// fall back to the default config file in the app folder
51+
if (!File.Exists(_configFile)) {
52+
_configFile = "~appFolder/mgdprc.json";
53+
}
54+
}
4855

4956
_configFile = Path.GetFullPath(ProxyUtils.ReplacePathTokens(_configFile));
5057

msgraph-developer-proxy/msgraph-developer-proxy.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
</ItemGroup>
4141

4242
<ItemGroup>
43-
<None Update="appsettings.json">
43+
<None Update="mgdprc.json">
4444
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
4545
</None>
4646
<None Update="picture.jpg">

msgraph-developer-proxy/presets/microsoft-graph-rate-limiting.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{
44
"name": "RateLimitingPlugin",
55
"enabled": true,
6-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
6+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
77
}
88
],
99
"urlsToWatch": [

msgraph-developer-proxy/presets/microsoft-graph.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
{
44
"name": "GraphSelectGuidancePlugin",
55
"enabled": true,
6-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
6+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
77
},
88
{
99
"name": "GraphBetaSupportGuidancePlugin",
1010
"enabled": true,
11-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
11+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
1212
"urlsToWatch": [
1313
"https://graph.microsoft.com/beta/*",
1414
"https://graph.microsoft.us/beta/*",
@@ -19,28 +19,28 @@
1919
{
2020
"name": "GraphSdkGuidancePlugin",
2121
"enabled": true,
22-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
22+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
2323
},
2424
{
2525
"name": "ODataPagingGuidancePlugin",
2626
"enabled": true,
27-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
27+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
2828
},
2929
{
3030
"name": "GraphClientRequestIdGuidancePlugin",
3131
"enabled": true,
32-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
32+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll"
3333
},
3434
{
3535
"name": "GraphRandomErrorPlugin",
3636
"enabled": true,
37-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
37+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
3838
"configSection": "graphRandomErrorsPlugin"
3939
},
4040
{
4141
"name": "ExecutionSummaryPlugin",
4242
"enabled": true,
43-
"pluginPath": "GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
43+
"pluginPath": "~appFolder\\GraphProxyPlugins\\msgraph-developer-proxy-plugins.dll",
4444
"configSection": "executionSummaryPlugin"
4545
}
4646
],

0 commit comments

Comments
 (0)