[
https://issues.apache.org/jira/browse/COUCHDB-2529?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14258234#comment-14258234
]
Alexander Fedorenchik commented on COUCHDB-2529:
------------------------------------------------
As a workaround I wrote a plugin, but as soon as I'm new to erlang, I believe
this could be done easier. (Especially part that compares database names).
{{
-export([handle_task_status_req/2]).
-import(couch_httpd,
[send_json/2,send_json/3,send_json/4,send_method_not_allowed/2]).
-import(couch_util, [get_value/2]).
is_correct_db(Data, Name) ->
S1 = lists:flatten(io_lib:format("~s", [proplists:get_value(database,
Data)])),
S2 = lists:flatten(io_lib:format("~s", [Name])),
(string:equal(S1, S2)).
handle_task_status_req(#httpd{method='GET'}=Req, Db) ->
DbName = ?b2l(Db#db.name),
send_json(Req, [{Props} || Props <- couch_task_status:all(),
is_correct_db(Props, DbName)]);
handle_task_status_req(Req, _Db) ->
send_method_not_allowed(Req, "GET").
}}
Any code review will be appreciated.
> Add _active_tasks handler to httpd_db_handlers
> ----------------------------------------------
>
> Key: COUCHDB-2529
> URL: https://issues.apache.org/jira/browse/COUCHDB-2529
> Project: CouchDB
> Issue Type: Wish
> Security Level: public(Regular issues)
> Reporter: Alexander Fedorenchik
>
> Add _active_tasks handler to httpd_db_handlers that will return same data as
> {couch_httpd_misc_handlers, handle_task_status_req}, but filtered by current
> database and without admin privileges.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)