Page MenuHomeSealhub

No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
diff --git a/bin/prometheus-modules/rest/rest.js b/bin/prometheus-modules/rest/rest.js
index dc42b1ec..60387bf0 100644
--- a/bin/prometheus-modules/rest/rest.js
+++ b/bin/prometheus-modules/rest/rest.js
@@ -1,94 +1,92 @@
module.exports.prepare_channel_rest = function(channel, dispatcher, dependencies){
//console.log("\nREST dependencies:", dependencies);
var www_server = dependencies["channel.www_server"];
var sessionManager = dependencies["service.session_manager"];
channel.add_path = function(url, resource_type_name){
www_server.route({
method: "GET",
path: url,
handler: function(request, reply){
dispatcher.resources_list_by_type(resource_type_name)
.then(function(resources){ // wywołanie metody z dispatchera webowego
//console.log("GOT RESPONSE FROM DISPATCHER");
//var resources_arr = resources.map(function(resource){return resource.getData()});
reply(resources);
});
}
// hanlder GET ma wypisać wszystkie zasoby o podanym typie
});
www_server.route({
method: "POST",
path: url,
handler: function(request, reply){
- //console.log(dispatcher.resources_create.toString());
- request.payload.owner = "1";
console.log("rest.js POST", request.payload, request.state.PrometheusSession);
var session = sessionManager.get_user_id(request.state.PrometheusSession.toString());
console.log(session);
var request_with_owner = {
payload : request.payload,
owner_id: session
}
dispatcher.resources_create(resource_type_name, request_with_owner).then(function(response){
reply(response.toString());
});
}
// handler POST ma stworzyć zasób z podanymi wartościami
});
www_server.route({
method: "DELETE",
path: url,
handler: function(request, reply){
//console.log("rest.js DELETE", request.payload)
dispatcher.resources_delete(resource_type_name, request.payload).then(function(response){
reply();
});
}
// handler POST ma stworzyć zasób z podanymi wartościami
});
www_server.route({
method: "GET",
path: url+"/{id}",
handler: function(request, reply){
//console.log("rest.js get_resource_by_id", request.params.id);
dispatcher.resources_get_by_id(request.params.id).then(function(response){
reply(response);
}).catch(function(error){
reply().statusCode = 409;
});
}
});
www_server.route({
method: "PUT",
path: url+"/{id}/access_mode",
handler: function(request, reply){
//console.log("rest.js get_resource_by_id", request.params.id, request.payload.access_mode, request.payload.access_mode_args);
dispatcher.resources_edit_resource_access_mode(request.params.id, request.payload.access_mode, request.payload.access_mode_args).then(function(response){
reply(response);
});
}
});
www_server.route({
method: "GET",
path: url+"/{id}/access_mode",
handler: function(request, reply){
//console.log("rest.js get_resource_access_mode_by_id");
dispatcher.resources_get_access_mode(request.params.id).then(function(response){
reply(response);
});
}
});
}
}
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 28, 03:16 (2 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1230161
Default Alt Text
(3 KB)

Event Timeline