Tidy up SampleApp.
This commit is contained in:
parent
9f720eda90
commit
efa37e5590
|
|
@ -15,26 +15,19 @@ namespace SampleApp
|
||||||
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
|
||||||
{
|
{
|
||||||
loggerFactory.AddConsole(LogLevel.Trace);
|
loggerFactory.AddConsole(LogLevel.Trace);
|
||||||
|
var logger = loggerFactory.CreateLogger("Default");
|
||||||
|
|
||||||
app.Run(async context =>
|
app.Run(async context =>
|
||||||
{
|
{
|
||||||
Console.WriteLine("{0} {1}{2}{3}",
|
|
||||||
context.Request.Method,
|
|
||||||
context.Request.PathBase,
|
|
||||||
context.Request.Path,
|
|
||||||
context.Request.QueryString);
|
|
||||||
Console.WriteLine($"Method: {context.Request.Method}");
|
|
||||||
Console.WriteLine($"PathBase: {context.Request.PathBase}");
|
|
||||||
Console.WriteLine($"Path: {context.Request.Path}");
|
|
||||||
Console.WriteLine($"QueryString: {context.Request.QueryString}");
|
|
||||||
|
|
||||||
var connectionFeature = context.Connection;
|
var connectionFeature = context.Connection;
|
||||||
Console.WriteLine($"Peer: {connectionFeature.RemoteIpAddress?.ToString()} {connectionFeature.RemotePort}");
|
logger.LogDebug($"Peer: {connectionFeature.RemoteIpAddress?.ToString()}:{connectionFeature.RemotePort}"
|
||||||
Console.WriteLine($"Sock: {connectionFeature.LocalIpAddress?.ToString()} {connectionFeature.LocalPort}");
|
+ $"{Environment.NewLine}"
|
||||||
|
+ $"Sock: {connectionFeature.LocalIpAddress?.ToString()}:{connectionFeature.LocalPort}");
|
||||||
|
|
||||||
context.Response.ContentLength = 11;
|
var response = $"hello, world{Environment.NewLine}";
|
||||||
|
context.Response.ContentLength = response.Length;
|
||||||
context.Response.ContentType = "text/plain";
|
context.Response.ContentType = "text/plain";
|
||||||
await context.Response.WriteAsync("Hello world");
|
await context.Response.WriteAsync(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue