Beispiel #1
0
        public static void Main(string[] args)
        {
            var config = new RestServerConfiguration
            {
                Host    = "+",
                WebRoot = string.Format("..{0}..{0}server{0}files{0}", Path.DirectorySeparatorChar)
            };

            SetLoggingEvents();

            RestServer server    = new RestServer(config);
            MyResource resources = new MyResource();

            server.AddResource(resources.FooRoute, resources.WriteMore);
            server.AddResource(resources.NotFoundRoute, resources.WriteNotFound);
            server.AddResource(resources.ExceptionRoute, (c) => { throw new Exception("exception happend"); });
            server.AddResource(resources.HtmlWithCssRoute, resources.WriteHtmlWithCss);
//            server.AddResource(route.MatchEverythingRoute, route.WriteRawUrl);
            server.Start();

            while (server.IsListening)
            {
                Thread.Sleep(300);
            }
        }