Exemplo n.º 1
0
        static void Main(string[] args)
        {
            TwinoServer server = new TwinoServer(ServerOptions.CreateDefault());

            server.UseHttp(async(request, response) =>
            {
                if (request.Path.Equals("/plaintext", StringComparison.InvariantCultureIgnoreCase))
                {
                    response.SetToText();
                    await response.WriteAsync("Hello, World!");
                }
                else
                {
                    response.StatusCode = HttpStatusCode.NotFound;
                }
            });

            server.Start(82);
            server.BlockWhileRunning();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            TwinoServer server = new TwinoServer(ServerOptions.CreateDefault());

            server.UseHttp(async(request, response) =>
            {
                if (request.Path.Equals("/json", StringComparison.InvariantCultureIgnoreCase))
                {
                    response.SetToJson(new { message = "Hello, World!" });
                }
                else
                {
                    response.StatusCode = HttpStatusCode.NotFound;
                }

                await Task.CompletedTask;
            }, HttpOptions.CreateDefault());

            server.Start();
            server.BlockWhileRunning();
        }