adding http methods (#208)

diff --git a/knative-build/runtimes/javascript/app.js b/knative-build/runtimes/javascript/app.js
index 61f7193..3f0eb26 100644
--- a/knative-build/runtimes/javascript/app.js
+++ b/knative-build/runtimes/javascript/app.js
@@ -71,7 +71,7 @@
 } else if (targetPlatform === runtime_platform.knative) {
     var platformFactory = require('./platform/platform.js');
     var platform = new platformFactory("knative", service, config);
-    app.post('/', platform.run);
+    platform.registerHandlers(app, platform)
 } else {
     console.error("Environment variable '__OW_RUNTIME_PLATFORM' has an unrecognized value ("+targetPlatform+").");
 }
diff --git a/knative-build/runtimes/javascript/buildtemplate.yaml b/knative-build/runtimes/javascript/buildtemplate.yaml
index e63e36f..dc7f70a 100644
--- a/knative-build/runtimes/javascript/buildtemplate.yaml
+++ b/knative-build/runtimes/javascript/buildtemplate.yaml
@@ -29,6 +29,9 @@
   - name: OW_ACTION_BINARY
     description: flag to indicate zip function, for zip actions, "__OW_ACTION_CODE" must be base64 encoded string
     default: "false"
+  - name: OW_HTTP_METHODS
+    description: list of HTTP methods, any combination of [GET, POST, PUT, and DELETE], default is [POST]
+    default: "[POST]"
   steps:
   - name: add-ow-env-to-dockerfile
     image: "gcr.io/kaniko-project/executor:debug"
diff --git a/knative-build/runtimes/javascript/platform/platform.js b/knative-build/runtimes/javascript/platform/platform.js
index d448b39..c6a5389 100644
--- a/knative-build/runtimes/javascript/platform/platform.js
+++ b/knative-build/runtimes/javascript/platform/platform.js
@@ -182,6 +182,8 @@
         // process per-activation (i.e, "run") data
         preProcessActivationData(env, activationData);
 
+        preProcessHTTPContext(req);
+
     } catch(e){
         console.error(e);
         DEBUG.functionEndError(e.message);
@@ -234,6 +236,7 @@
     DEBUG.functionEnd();
 }
 
+
 function PlatformFactory(id, svc, cfg) {
 
     DEBUG.dumpObject(id, "Platform" );
@@ -268,6 +271,40 @@
             res.status(500).json({error: "internal error"})
         }
     }
+
+    var http_method = {
+        get: 'GET',
+        post: 'POST',
+        put: 'PUT',
+        delete: 'DELETE',
+    };
+
+    this.registerHandlers = function(app, platform) {
+            var httpMethods = process.env.__OW_HTTP_METHODS;
+            // default to "[post]" HTTP method if not defined
+            if (typeof httpMethods === "undefined" || !Array.isArray(httpMethods)) {
+                console.error("__OW_HTTP_METHODS is undefined; defaulting to '[post]' ...");
+                httpMethods = [http_method.post];
+            }
+            httpMethods.forEach(function (method) {
+                switch (method.toUpperCase()) {
+                    case http_method.get:
+                        app.get('/', platform.run);
+                        break;
+                    case http_method.post:
+                        app.post('/', platform.run);
+                        break;
+                    case http_method.put:
+                        app.put('/', platform.run);
+                        break;
+                    case http_method.delete:
+                        app.delete('/', platform.run);
+                        break;
+                    default:
+                        console.error("Environment variable '__OW_HTTP_METHODS' has an unrecognized value (" + method + ").");
+                }
+            });
+    }
 };
 
 module.exports = PlatformFactory;