|
@@ -4,13 +4,19 @@ using System.Threading.Tasks;
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
using System;
|
|
|
using System.Threading;
|
|
|
+using System.Text;
|
|
|
namespace Benchmarks
|
|
|
{
|
|
|
[BeetleX.FastHttpApi.Controller]
|
|
|
class Program
|
|
|
{
|
|
|
+ private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
|
|
|
+
|
|
|
+ private static StringBytes plaintextResult;
|
|
|
+
|
|
|
public static void Main(string[] args)
|
|
|
{
|
|
|
+ plaintextResult = new StringBytes(_helloWorldPayload);
|
|
|
var builder = new HostBuilder()
|
|
|
.ConfigureServices((hostContext, services) =>
|
|
|
{
|
|
@@ -22,7 +28,7 @@ namespace Benchmarks
|
|
|
public object plaintext(IHttpContext context)
|
|
|
{
|
|
|
context.Response.Header[HeaderTypeFactory.DATE] = DateTime.Now.ToUniversalTime().ToString("r");
|
|
|
- return new TextResult("Hello, World!");
|
|
|
+ return plaintextResult;
|
|
|
}
|
|
|
|
|
|
public object json(IHttpContext context)
|
|
@@ -30,13 +36,13 @@ namespace Benchmarks
|
|
|
context.Response.Header[HeaderTypeFactory.DATE] = DateTime.Now.ToUniversalTime().ToString("r");
|
|
|
return new JsonResult(new JsonMessage { message = "Hello, World!" });
|
|
|
}
|
|
|
-
|
|
|
public class JsonMessage
|
|
|
{
|
|
|
public string message { get; set; }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
public class BeetleXHttpServer : IHostedService
|
|
|
{
|
|
|
private HttpApiServer mApiServer;
|