Skip to content

Commit 9552ed9

Browse files
committed
fixed bug on csharp
1 parent 343df47 commit 9552ed9

File tree

9 files changed

+1230
-22
lines changed

9 files changed

+1230
-22
lines changed
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"iisSettings": {
3+
"windowsAuthentication": false,
4+
"anonymousAuthentication": true,
5+
"iisExpress": {
6+
"applicationUrl": "http://localhost:9836/",
7+
"sslPort": 0
8+
}
9+
},
10+
"profiles": {
11+
"IIS Express": {
12+
"commandName": "IISExpress",
13+
"launchBrowser": true,
14+
"environmentVariables": {
15+
"ASPNETCORE_ENVIRONMENT": "Development"
16+
}
17+
}
18+
}
19+
}

src/WebApiProxy.Core/Infrastructure/StringExtensions.cs

+4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ public static string ToCamelCasing(this string helper)
3030
/// <returns>The xml documentation format.</returns>
3131
public static string ToSummary(this string description)
3232
{
33+
if (String.IsNullOrEmpty(description))
34+
{
35+
return "";
36+
}
3337
return Regex.Replace(description, "\n\\s*", "\n\t\t/// ");
3438
}
3539

src/WebApiProxy.Middleware.JQuery/JQueryClientProviderMiddleware.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,14 @@ public JQueryClientProviderMiddleware(
1818

1919
public async override Task Invoke(HttpContext httpContext)
2020
{
21-
await base.ProcessRequest(httpContext);
21+
if (await base.ProcessRequest(httpContext))
22+
{
23+
IGenerator generator = new JQueryGenerator(metadata);
24+
var result = await generator.Process();
25+
await httpContext.Response.WriteAsync(result);
26+
}
2227

23-
IGenerator generator = new JQueryGenerator(metadata);
24-
var result = await generator.Process();
25-
await httpContext.Response.WriteAsync(result);
28+
2629

2730
}
2831

src/WebApiProxy.Middleware/WebApiProxyMetadataProviderMiddleware.cs

+11-8
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@ IOptions<WebApiProxyProviderOptions> options
1616
public async override Task Invoke(HttpContext httpContext)
1717
{
1818

19-
await base.ProcessRequest(httpContext);
20-
21-
var response = httpContext.Response;
22-
response.StatusCode = 200;
23-
response.ContentType = "application/json";
24-
using (var writer = new StreamWriter(response.Body))
19+
if (await base.ProcessRequest(httpContext))
2520
{
26-
var output = JsonConvert.SerializeObject(metadata);
21+
var response = httpContext.Response;
22+
response.StatusCode = 200;
23+
response.ContentType = "application/json";
24+
using (var writer = new StreamWriter(response.Body))
25+
{
26+
var output = JsonConvert.SerializeObject(metadata);
2727

28-
writer.Write(output);
28+
writer.Write(output);
29+
}
2930
}
31+
32+
3033
}
3134
}
3235
}

src/WebApiProxy.Middleware/WebApiProxyMiddlewareBase.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,19 @@ WebApiProxyOptions options
2424
}
2525
public abstract Task Invoke(HttpContext httpContext);
2626

27-
protected virtual async Task ProcessRequest(HttpContext httpContext)
27+
protected virtual async Task<bool> ProcessRequest(HttpContext httpContext)
2828
{
2929
if (!ValidateRequest(httpContext.Request))
3030
{
3131
await next(httpContext);
32-
return;
32+
return false;
3333
}
3434

3535
var host = $"{httpContext.Request.Scheme}://{httpContext.Request.Host}";
3636

3737
metadata = metadataProvider.GetMetadata(host);
38+
39+
return true;
3840
}
3941

4042
protected virtual bool ValidateRequest(HttpRequest request)

0 commit comments

Comments
 (0)