All filters declare a yp2_filter_struct - used for both static and
[metaproxy-moved-to-github.git] / src / ex_filter_frontend_net.cpp
index fd5d7d7..b77a063 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ex_filter_frontend_net.cpp,v 1.9 2005-10-25 15:19:58 adam Exp $
+/* $Id: ex_filter_frontend_net.cpp,v 1.20 2006-01-04 11:19:04 adam Exp $
    Copyright (c) 2005, Index Data.
 
 %LICENSE%
@@ -13,12 +13,14 @@ namespace po = boost::program_options;
 
 #include "config.hpp"
 
+#include "util.hpp"
 #include "filter_frontend_net.hpp"
 #include "filter_z3950_client.hpp"
 #include "filter_virt_db.hpp"
+#include "filter_session_shared.hpp"
 #include "filter_log.hpp"
 
-#include "router.hpp"
+#include "router_chain.hpp"
 #include "session.hpp"
 #include "package.hpp"
 
@@ -33,7 +35,7 @@ public:
         Z_GDU *gdu = package.request().get();
         if (gdu && gdu->which == Z_GDU_HTTP_Request)
         {
-            ODR odr = odr_createmem(ODR_ENCODE);
+            yp2::odr odr;
             Z_GDU *gdu = z_get_HTTP_Response(odr, 200);
             Z_HTTP_Response *http_res = gdu->u.HTTP_Response;
             
@@ -45,7 +47,6 @@ public:
             http_res->content_len = strlen(http_res->content_buf);
             
             package.response() = gdu;
-            odr_destroy(odr);
         }
         return package.move();
     };
@@ -94,25 +95,32 @@ int main(int argc, char **argv)
             if (vm.count("duration")) {
                 filter_front.listen_duration() = vm["duration"].as<int>();
             }
-           router.rule(filter_front);
+           router.append(filter_front);
 
             // put log filter in router
-            yp2::filter::Log filter_log;
-            router.rule(filter_log);
+            yp2::filter::Log filter_log_front("FRONT");
+            router.append(filter_log_front);
 
             // put Virt db filter in router
             yp2::filter::Virt_db filter_virt_db;
-            filter_virt_db.add_map_db2vhost("Default", "indexdata.dk/gils");
+            filter_virt_db.add_map_db2vhost("gils", "indexdata.dk/gils");
+            filter_virt_db.add_map_db2vhost("Default", "localhost:9999/Default");
+            filter_virt_db.add_map_db2vhost("2", "localhost:9999/2");
+           // router.append(filter_virt_db);
 
-           router.rule(filter_virt_db);
+            yp2::filter::SessionShared filter_session_shared;
+            //router.append(filter_session_shared);
+
+            yp2::filter::Log filter_log_back("BACK");
+            router.append(filter_log_back);
 
             // put HTTP backend filter in router
             HTTPFilter filter_init;
-           router.rule(filter_init);
+           router.append(filter_init);
 
             // put Z39.50 backend filter in router
             yp2::filter::Z3950Client z3950_client;
-           router.rule(z3950_client);
+           router.append(z3950_client);
 
             yp2::Session session;
             yp2::Origin origin;