var jsforce = require("jsforce")
    , session = require("express-session")
    , config = require("../config")

exports.index = function(req, res, next) {
    res.render('rest', {
        "rest": {
            "uri": "/services/data/v" + config.apiVersion + ".0/sobjects",
            "header": {
                "Content-Type" : "application/json"
            }
        }
    });
}

exports.executeRest = function(req, res, next) {
    var _request = {
        url: req.body.url,
        method: req.body.method,
        body: req.body.body,
        headers : JSON.parse(req.body.header)
    }

    console.log(_request);

    var conn = new jsforce.Connection({
        accessToken: req.session.accessToken,
        instanceUrl: req.session.instanceUrl
    });

    conn.request(_request, function(err, resp) {
        if (err) return res.send(err.toString());
        res.send(resp)
    })
}
@@ -321,17 +321,131 @@
 nt-Type%22
- 
+: %22application/json%22,%0A                %22Authorization%22: %22OAuth %22 + req.session.accessToken,%0A                %22Accept%22
 : %22appli

update rest header