From aa2a639f0e6210caed58b307a4e9e941a4053998 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/OpenSRF/trunk@447 9efc2488-bf62-4759-914b-345cdb29e865 --- src/gateway/Makefile | 6 +++--- src/gateway/fieldmapper-c-xml-out.pl | 1 + src/gateway/mod_ils_gateway.c | 30 ++++++++++++++++++++++++---- 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/gateway/Makefile b/src/gateway/Makefile index b587761..1743f94 100644 --- a/src/gateway/Makefile +++ b/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/src/gateway/fieldmapper-c-xml-out.pl b/src/gateway/fieldmapper-c-xml-out.pl index ce9f5de..fc9e563 100755 --- a/src/gateway/fieldmapper-c-xml-out.pl +++ b/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/src/gateway/mod_ils_gateway.c b/src/gateway/mod_ils_gateway.c index c1e69fc..123509a 100644 --- a/src/gateway/mod_ils_gateway.c +++ b/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 + -- 2.43.2