Exemplo n.º 1
0
 public void ForGenericType()
 {
     using (var server = RestServer.For <CustomSettings>())
     {
         server.Port.ShouldBe("5555");
     }
 }
Exemplo n.º 2
0
        public static void NestedClosures()
        {
            var server = RestServer.For(s =>
            {
                s.Router = Router.For(r =>
                {
                    r.Register(Route.For(HttpMethod.GET).Use(ctx =>
                    {
                        ctx.Dynamic.Token = "some_token";
                        return(ctx);
                    }));

                    r.Register(Route.For(HttpMethod.GET).To("/api/.*").Use(ctx =>
                    {
                        ctx.Response.AppendCookie(new Cookie {
                            Name = "Token", Value = ctx.Dynamic.Token
                        });
                        var response = ctx.Request.Headers.Get("SomeKey");
                        ctx.Response.SendResponse(response);
                        return(ctx);
                    }));
                });
            });

            server.Start();

            System.Console.Write("Running Nested Closures Instance...");
            System.Console.ReadLine();

            server.Stop();
            System.Console.WriteLine("done");
        }
Exemplo n.º 3
0
            public void ForAction()
            {
                const string port  = "5555";
                const string index = "default.htm";

                using (var server = RestServer.For(_ =>
                {
                    _.Port = port;
                    _.PublicFolder.DefaultFileName = index;
                }))
                {
                    server.Port.ShouldBe(port);
                    server.PublicFolder.DefaultFileName.ShouldBe(index);
                }
            }