Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
addDynamicSSLPlugin: function (fds, req, res) {
return unirest.post(req.connection.kong_admin_url + req.url.replace('/kong', ''))
.headers({'Content-Type': 'multipart/form-data'})
.field('name', req.body.name)
.field('config.only_https', req.body['config.only_https'] || false)
.field('config.accept_http_if_already_terminated', req.body['config.accept_http_if_already_terminated'] || false)
.attach('config.cert', fds[0])
.attach('config.key', fds[1])
.end(function (response) {
if (response.error) return res.kongError(response)
return res.json(response.body)
});
},
create: function (req, res) {
unirest.post(Utils.withoutTrailingSlash(req.connection.kong_admin_url) + req.url.replace('/kong', ''))
.headers(KongService.headers(req, true))
.send(req.body)
.end(function (response) {
if (response.error) return res.kongError(response);
return res.json(response.body);
});
},
post(path, data, callback) {
unirest.post(this.endpoint + path)
.headers({"Accept":"application/json", "Content-Type":"application/json"})
.send(data)
.end(callback);
}
function post(opts) {
var data = opts.data || {};
return unirest.post(opts.url)
.header('Accept', 'application/json')
.header('Content-Type', 'application/json')
.send(data);
}