-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadapter.coffee
More file actions
33 lines (29 loc) · 839 Bytes
/
adapter.coffee
File metadata and controls
33 lines (29 loc) · 839 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
http = require("http")
###
req =
url: "/graph/..."
method: "GET" or "POST" or "DELETE" or "PUT"
body: {} or "" if "POST" or "PUT"
full list of the available RESTapi to rexter:
https://github.com/tinkerpop/rexster/wiki/Basic-REST-API
###
module.exports.proxyRequest = (req, resultHandler) ->
r =
host: "localhost"
path: req.url
method: req.method
port: 8182
request = http.request r, (resp) ->
body = ""
resp.on "data", (chunk) ->
body += chunk.toString()
resp.on "end", () ->
if resp.statusCode != 200
console.log resp.statusCode, body
resultHandler {error: resp.statusCode, message: body}, null
else
resultHandler null, body
request.on "error", (error)->
resultHandler {error: error}, null
request.write req.body.toString() if req.body
request.end()