From dc662cee02711d1e980fca2c56dfe1d34f7996a2 Mon Sep 17 00:00:00 2001
From: dbs <dbs@9efc2488-bf62-4759-914b-345cdb29e865>
Date: Thu, 28 Jan 2010 03:10:23 +0000
Subject: [PATCH] Add an example Apache virtual host configuration and curl
 script for testing the math service

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1905 9efc2488-bf62-4759-914b-345cdb29e865
---
 examples/apache2/opensrf     | 49 ++++++++++++++++++++++++++++++++++++++++++++
 examples/math_client_curl.sh |  8 ++++++++
 2 files changed, 57 insertions(+)
 create mode 100644 examples/apache2/opensrf
 create mode 100644 examples/math_client_curl.sh

diff --git a/examples/apache2/opensrf b/examples/apache2/opensrf
new file mode 100644
index 0000000..2989dc0
--- /dev/null
+++ b/examples/apache2/opensrf
@@ -0,0 +1,49 @@
+# This is a barebones Apache virtual host configuration, suitable
+# for testing out the OpenSRF gateway and HTTP translator, and
+# that's about it.
+
+NameVirtualHost *:80
+<VirtualHost *:80>
+	ServerName localhost:80
+	ServerAlias 127.0.0.1:80
+ 	#DocumentRoot /openils/var/web/
+	#DirectoryIndex index.xml index.html index.xhtml
+
+	# ----------------------------------------------------------------------------------
+	# Configure the gateway
+	# ----------------------------------------------------------------------------------
+	OSRFGatewayConfig /openils/conf/opensrf_core.xml
+	# Translator memcache server.  Default is localhost
+	# OSRFTranslatorCacheServer 127.0.0.1:11211
+
+	# ----------------------------------------------------------------------------------
+	# XXX Note, it's important to explicitly set the JSON encoding style 
+	# (OSRFGatewayLegacyJSON), since the default encoding style will likely change 
+	# with OpenSRF 1.0
+	# ----------------------------------------------------------------------------------
+	# OpenSRF JSON legacy gateway
+	# ----------------------------------------------------------------------------------
+	<Location /gateway>
+		SetHandler osrf_json_gateway_module
+		OSRFGatewayLegacyJSON "true"
+		allow from all
+	</Location>
+	# ----------------------------------------------------------------------------------
+	# New-style OpenSRF JSON gateway
+	# ----------------------------------------------------------------------------------
+	<Location /osrf-gateway-v1>
+		SetHandler osrf_json_gateway_module
+		OSRFGatewayLegacyJSON "false"
+		allow from all
+	</Location>
+
+	# ----------------------------------------------------------------------------------
+	# OpenSRF-over-HTTP translator
+	# (http://open-ils.org/dokuwiki/doku.php?id=opensrf_over_http)
+	# ----------------------------------------------------------------------------------
+	<Location /osrf-http-translator>
+		SetHandler osrf_http_translator_module
+		allow from all
+	</Location>
+
+</VirtualHost>
diff --git a/examples/math_client_curl.sh b/examples/math_client_curl.sh
new file mode 100644
index 0000000..3f3fb6e
--- /dev/null
+++ b/examples/math_client_curl.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+# Simple demonstration of invoking a public OpenSRF method via curl
+
+# Expected output will be something like:
+# [{"__c":"osrfMessage","__p":{"threadTrace":"0","locale":"en-CA","type":"RESULT","payload":{"__c":"osrfResult","__p":{"status":"OK","statusCode":"200","content":4}}}},{"__c":"osrfMessage","__p":{"threadTrace":"0","locale":"en-CA","type":"STATUS","payload":{"__c":"osrfConnectStatus","__p":{"status":"Request Complete","statusCode":"205"}}}}]
+
+curl -H "X-OpenSRF-service: opensrf.math" --data 'osrf-msg=[{"__c":"osrfMessage","__p":{"threadTrace":0,"type":"REQUEST","payload":{"__c":"osrfMethod","__p":{"method":"add","params":[2,2]}},"locale":"en-CA"}}]' http://localhost/osrf-http-translator
-- 
2.11.0