From a2d50fab0e7f439016c5cf73213d31e98e8253f8 Mon Sep 17 00:00:00 2001 From: miker Date: Tue, 2 Aug 2005 19:34:32 +0000 Subject: [PATCH] the rest gatewaty, eets alive! git-svn-id: svn://svn.open-ils.org/ILS/trunk@1585 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- OpenSRF/src/gateway/Makefile | 6 ++-- OpenSRF/src/gateway/fieldmapper-c-xml-out.pl | 1 + OpenSRF/src/gateway/mod_ils_gateway.c | 30 +++++++++++++++++--- install.sh | 1 - 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/OpenSRF/src/gateway/Makefile b/OpenSRF/src/gateway/Makefile index b587761246..1743f94926 100644 --- a/OpenSRF/src/gateway/Makefile +++ b/OpenSRF/src/gateway/Makefile @@ -5,9 +5,9 @@ all: libmod_ils_gateway.so rest_gateway: libmod_ils_rest_gateway.so install: - cp $(TMPDIR)/libmod_ils_gateway.so $(LIBDIR)/libmod_ils_gateway.so cp gateway.xml.example $(ETCDIR) - $(APXS2) -i -a -n ils_gateway $(LIBDIR)/libmod_ils_gateway.so + $(APXS2) -i -a -n ils_gateway $(TMPDIR)/libmod_ils_gateway.so + $(APXS2) -i -a -n ils_rest_gateway $(TMPDIR)/libmod_ils_rest_gateway.so libmod_ils_gateway.so: mod_ils_gateway.c $(CC) -c $(CC_OPTS) mod_ils_gateway.c @@ -17,7 +17,7 @@ libmod_ils_rest_gateway.so: mod_ils_gateway.c ./fieldmapper-c-xml-out.pl rest_xml.h rest_xml.c $(CC) -c $(CC_OPTS) -o rest_xml.o rest_xml.c $(CC) -c -DRESTGATEWAY $(CC_OPTS) -o mod_ils_rest_gateway.o mod_ils_gateway.c - $(CC) $(LD_OPTS) -shared -W1 mod_ils_rest_gateway.o -o $(TMPDIR)/libmod_ils_rest_gateway.so + $(CC) $(LD_OPTS) -shared -W1 rest_xml.o mod_ils_rest_gateway.o -o $(TMPDIR)/libmod_ils_rest_gateway.so clean: /bin/rm -f *.o *.so diff --git a/OpenSRF/src/gateway/fieldmapper-c-xml-out.pl b/OpenSRF/src/gateway/fieldmapper-c-xml-out.pl index ce9f5de9dc..fc9e563402 100755 --- a/OpenSRF/src/gateway/fieldmapper-c-xml-out.pl +++ b/OpenSRF/src/gateway/fieldmapper-c-xml-out.pl @@ -1,6 +1,7 @@ #!/usr/bin/perl use strict; use warnings; use lib '../../../Open-ILS/src/perlmods/'; +use lib '../perlmods/'; use OpenILS::Utils::Fieldmapper; diff --git a/OpenSRF/src/gateway/mod_ils_gateway.c b/OpenSRF/src/gateway/mod_ils_gateway.c index c1e69fcb03..123509a20b 100644 --- a/OpenSRF/src/gateway/mod_ils_gateway.c +++ b/OpenSRF/src/gateway/mod_ils_gateway.c @@ -39,7 +39,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #ifdef RESTGATEWAY #include "rest_xml.h" -#endif /* * This function is registered as a handler for HTTP methods and will @@ -48,7 +47,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * STDERR (which httpd redirects to logs/error_log). A real module * would do *alot* more at this point. */ +#define MODULE_NAME "ils_rest_gateway_module" +#else #define MODULE_NAME "ils_gateway_module" +#endif /* struct session_list_struct { @@ -186,9 +188,6 @@ static int mod_ils_gateway_method_handler (request_rec *r) { return HTTP_INTERNAL_SERVER_ERROR; } - /* set content type to text/plain for passing around JSON objects */ - ap_set_content_type(r, "text/plain"); - /* gather the post args and append them to the url query string */ @@ -370,8 +369,14 @@ static int mod_ils_gateway_method_handler (request_rec *r) { free_object(exception); } else { #ifdef RESTGATEWAY + /* set content type to text/xml for passing around XML objects */ + ap_set_content_type(r, "text/xml"); + content = json_string_to_xml( buffer_data(result_data) ); #else + /* set content type to text/plain for passing around JSON objects */ + ap_set_content_type(r, "text/plain"); + content = buffer_data(result_data); #endif } @@ -413,6 +418,21 @@ static void mod_ils_gateway_register_hooks (apr_pool_t *p) { * only "glue" between the httpd core and the module. */ +#ifdef RESTGATEWAY + +module AP_MODULE_DECLARE_DATA ils_rest_gateway_module = +{ +STANDARD20_MODULE_STUFF, +NULL, +NULL, +NULL, +NULL, +NULL, +mod_ils_gateway_register_hooks, +}; + +#else + module AP_MODULE_DECLARE_DATA ils_gateway_module = { STANDARD20_MODULE_STUFF, @@ -424,3 +444,5 @@ NULL, mod_ils_gateway_register_hooks, }; +#endif + diff --git a/install.sh b/install.sh index 246f6c9e3a..2536a43edd 100755 --- a/install.sh +++ b/install.sh @@ -157,7 +157,6 @@ function runInstall { if building; then $MAKE -C "$OPENSRFDIR" "gateway"; fi; if building; then $MAKE -C "$OPENSRFDIR" "rest_gateway"; fi; if installing; then $MAKE -C "$OPENSRFDIR" "gateway-install"; fi; - if installing; then $MAKE -C "$OPENSRFDIR" "rest_gateway-install"; fi; ;; "opensrf_srfsh" ) -- 2.43.2