public void ForGenericType() { using (var server = RestServer.For <CustomSettings>()) { server.Port.ShouldBe("5555"); } }
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"); }
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); } }