Page Menu
Home
Sealhub
Search
Configure Global Search
Log In
Files
F22422073
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/bin/prometheus-modules/rest/rest.js b/bin/prometheus-modules/rest/rest.js
index a34e1aef..65a9e915 100644
--- a/bin/prometheus-modules/rest/rest.js
+++ b/bin/prometheus-modules/rest/rest.js
@@ -1,82 +1,94 @@
module.exports.prepare_channel_rest = function(channel, dispatcher, dependencies){
//console.log("\nREST dependencies:", dependencies);
var www_server = dependencies["channel.www_server"];
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());
//console.log("rest.js POST", request.payload)
dispatcher.resources_create(resource_type_name, request.payload).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: "PUT",
+ path: url+"/{id}",
+ 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_update(request.params.id, request.payload).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
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 28, 03:16 (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1230162
Default Alt Text
(3 KB)
Attached To
Mode
rS Sealious
Attached
Detach File
Event Timeline