Пример #1
0
        public void RouterCanRouteSimpleResource()
        {
            var router = new Router();

              bool routerDidRoute = false;

              router.Route(HttpMethods.Get, "/test", (req, res) =>
              {
            routerDidRoute = true;
              });

              // Need to mock httplistenercontext to be able to test for real.
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var router = new Router();
              router.Route(HttpMethods.Get, "/entities", Callback);
              router.Route(HttpMethods.Get, "/entities/", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}/", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}/names", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}/names/", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}/names/{nameId}", Callback);
              router.Route(HttpMethods.Get, "/entities/{userId}/names/{nameId}/", Callback);

              using (var httpServer = new HttpServer(router))
              {
            Console.ReadLine();
              }
        }