Ejemplo n.º 1
0
 public StaticContentRoute(StaticContentHandler handler)
 {
     Handler = handler;
 }
Ejemplo n.º 2
0
        static void SetupRoutes()
        {
            var httpd = new HttpServer();
            var router = new HttpRouter();

            httpd.Request = router.Route;
            httpd.LogRequests = Config.Log;

            var staticResources = new StaticContentHandler("./Static");
            router.AddRoute(new StaticContentRoute(staticResources));

            var mvc = new MvcRouter();

            mvc.RegisterController(new IndexController());
            mvc.RegisterController(new AdminController());
            mvc.RegisterController(new TestController());

            // Index //
            mvc.AddRoute("Login", "/", new { controller = "Index", action = "Index" });
            mvc.AddRoute("Login", "{action}", new { controller = "Index", action = "DoLogin" });

            mvc.AddRoute("Admin", "{controller}", new { controller = "Admin", action = "Index" });

            mvc.AddRoute("Test", "{action}", new { controller = "Test", action = "TestRedirect" });

            router.AddRoute(mvc);

            httpd.Start(new IPEndPoint(IPAddress.Parse(Config.BindingAddress), Config.BindingPort));

            Console.WriteLine("Server started on port " + Config.BindingPort);
        }