Add Plaintext sample (#2312)

This commit is contained in:
Ben Adams 2018-02-10 21:18:21 +00:00 committed by David Fowler
parent 2156030460
commit f65e89294d
3 changed files with 73 additions and 0 deletions

View File

@ -124,6 +124,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Http2SampleApp", "samples\H
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SystemdTestApp", "samples\SystemdTestApp\SystemdTestApp.csproj", "{A7994A41-CAF8-47A7-8975-F101F75B5BC1}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PlaintextApp", "samples\PlaintextApp\PlaintextApp.csproj", "{CE5523AE-6E38-4E20-998F-C64E02C5CC51}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -350,6 +352,18 @@ Global
{A7994A41-CAF8-47A7-8975-F101F75B5BC1}.Release|x64.Build.0 = Release|Any CPU
{A7994A41-CAF8-47A7-8975-F101F75B5BC1}.Release|x86.ActiveCfg = Release|Any CPU
{A7994A41-CAF8-47A7-8975-F101F75B5BC1}.Release|x86.Build.0 = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|x64.ActiveCfg = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|x64.Build.0 = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|x86.ActiveCfg = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Debug|x86.Build.0 = Debug|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|Any CPU.Build.0 = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|x64.ActiveCfg = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|x64.Build.0 = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|x86.ActiveCfg = Release|Any CPU
{CE5523AE-6E38-4E20-998F-C64E02C5CC51}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -375,6 +389,7 @@ Global
{9C7B6B5F-088A-436E-834B-6373EA36DEEE} = {D3273454-EA07-41D2-BF0B-FCC3675C2483}
{7BC22A4A-15D2-44C2-AB45-049F0FB562FA} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE}
{A7994A41-CAF8-47A7-8975-F101F75B5BC1} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE}
{CE5523AE-6E38-4E20-998F-C64E02C5CC51} = {8A3D00B8-1CCF-4BE6-A060-11104CE2D9CE}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2D10D020-6770-47CA-BB8D-2C23FE3AE071}

View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;net461</TargetFrameworks>
<IsPackable>false</IsPackable>
<NoDefaultLaunchSettingsFile>true</NoDefaultLaunchSettingsFile>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\Kestrel\Kestrel.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,45 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
namespace PlaintextApp
{
public class Startup
{
private static readonly byte[] _helloWorldBytes = Encoding.UTF8.GetBytes("Hello, World!");
public void Configure(IApplicationBuilder app)
{
app.Run((httpContext) =>
{
var response = httpContext.Response;
response.StatusCode = 200;
response.ContentType = "text/plain";
var helloWorld = _helloWorldBytes;
response.ContentLength = helloWorld.Length;
return response.Body.WriteAsync(helloWorld, 0, helloWorld.Length);
});
}
public static Task Main(string[] args)
{
var host = new WebHostBuilder()
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 5001);
})
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.Build();
return host.RunAsync();
}
}
}