Esempio n. 1
0
        public void TestRoutingWithManualRoutes()
        {
            var inst = new ControllerItems.ApiExampleController();

            using (var server = new ServerRunner(
                       new Ceen.Httpd.ServerConfig()
                       .AddLogger(new Ceen.Httpd.Logging.StdOutErrors())
                       .AddRoute(
                           new ManualRoutingController()
                           // We need to supply the function argument types, as C# does not support
                           // automatic inference of these
                           .Wire <IHttpContext>("GET /api/v1/entry", inst.Index)
                           .Wire <IHttpContext, int, string>("GET /api/v1/entry/{id}", inst.Index)
                           .Wire <IHttpContext, int>("GET /api/v1/entry/{id}/detail", inst.Cross)
                           .Wire <int>("POST /api/v1/entry/{id}", inst.Update)
                           .Wire <IHttpContext>("GET /api/v1/entry/detail", inst.Detail)
                           .Wire <IHttpContext, int>("GET|POST /api/v1/entry/detail/{id}", inst.Detail)
                           // If the methods have no arguments, we do not need to supply types
                           .Wire("* /home", new ControllerItems.HomeController().Index)
                           .Wire("GET /api/v1/wait", new ControllerItems.WaitExample().Index)
                           .ToRoute()
                           )))
            {
                CommonTesting(server);
            }
        }
Esempio n. 2
0
        public void TestRoutingWithManualFromConfig1()
        {
            var inst = new ControllerItems.ApiExampleController();

            var filepath = System.IO.Path.Combine(
                System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
                , "mvc.test1.txt");

            var cfg = Ceen.Httpd.Cli.ConfigParser.ParseTextFile(filepath);

            using (var server = new ServerRunner(
                       Ceen.Httpd.Cli.ConfigParser.ValidateConfig(cfg)
                       .AddLogger(new Ceen.Httpd.Logging.StdOutErrors())
                       ))
            {
                CommonTesting(server);
            }
        }