public static Task Main(string[] args)
        {
            var parsedArgs = Args.Parse(args);

            if (parsedArgs.Benchmark)
            {
                BenchmarkInHarness(parsedArgs);
                return(Task.CompletedTask);
            }

            IServerApplication app = null;

            if (parsedArgs.Mode == Mode.Raw)
            {
                app = new PlainTextRawApplication();
            }
            else if (parsedArgs.Mode == Mode.Features)
            {
                app = new PlainTextApplication();
            }
            else if (parsedArgs.Mode == Mode.RawWithHeaders)
            {
                app = new PlainTextRawWithHeadersApplication();
            }
            else
            {
                app = new HttpServer <BenchmarkHandler>();
            }

            var lifetime         = new ApplicationLifetime(NullLoggerFactory.Instance.CreateLogger <ApplicationLifetime>());
            var binding          = new IPEndPointInformation(new IPEndPoint(IPAddress.Any, parsedArgs.Port));
            var transportFactory = CreateTransport(parsedArgs, lifetime);

            return(app.RunAsync(transportFactory, binding, lifetime));
        }
示例#2
0
        public static Task Main(string[] args)
        {
            var parsedArgs = Args.Parse(args);

            IServerApplication app;

            if (parsedArgs.Mode == Mode.Raw)
            {
                app = new PlainTextRawApplication();
            }
            else if (parsedArgs.Mode == Mode.Features)
            {
                app = new PlainTextApplication();
            }
            else if (parsedArgs.Mode == Mode.RawWithHeaders)
            {
                app = new PlainTextRawWithHeadersApplication();
            }
            else
            {
                app = new HttpServer <BenchmarkHandler>();
            }

            return(app.RunAsync(parsedArgs.Port, parsedArgs.ThreadCount));
        }