1515
1616-module (dreyfus_httpd ).
1717
18- -export ([handle_search_req /3 , handle_info_req /3 ,
18+ -export ([handle_search_req /3 , handle_info_req /3 , handle_disk_size_req / 3 ,
1919 handle_cleanup_req /2 , handle_analyze_req /1 ]).
2020-include (" dreyfus.hrl" ).
2121-include_lib (" couch/include/couch_db.hrl" ).
@@ -108,7 +108,7 @@ handle_search_req(Req, _Db, _DDoc, _RetryCount, _RetryPause) ->
108108
109109handle_info_req (# httpd {method = 'GET' , path_parts = [_ , _ , _ , _ , IndexName ]}= Req
110110 ,# db {name = DbName }, # doc {id = Id }= DDoc ) ->
111- case dreyfus_fabric_info :go (DbName , DDoc , IndexName ) of
111+ case dreyfus_fabric_info :go (DbName , DDoc , IndexName , info ) of
112112 {ok , IndexInfoList } ->
113113 send_json (Req , 200 , {[
114114 {name , <<Id /binary ," /" ,IndexName /binary >>},
@@ -122,6 +122,21 @@ handle_info_req(#httpd{path_parts=[_, _, _, _, _]}=Req, _Db, _DDoc) ->
122122handle_info_req (Req , _Db , _DDoc ) ->
123123 send_error (Req , {bad_request , " path not recognized" }).
124124
125+ handle_disk_size_req (# httpd {method = 'GET' , path_parts = [_ , _ , _ , _ , IndexName ]}= Req , # db {name = DbName }, # doc {id = Id }= DDoc ) ->
126+ case dreyfus_fabric_info :go (DbName , DDoc , IndexName , disk_size ) of
127+ {ok , IndexInfoList } ->
128+ send_json (Req , 200 , {[
129+ {name , <<Id /binary ," /" ,IndexName /binary >>},
130+ {search_index , {IndexInfoList }}
131+ ]});
132+ {error , Reason } ->
133+ send_error (Req , Reason )
134+ end ;
135+ handle_disk_size_req (# httpd {path_parts = [_ , _ , _ , _ , _ ]}= Req , _Db , _DDoc ) ->
136+ send_method_not_allowed (Req , " GET" );
137+ handle_disk_size_req (Req , _Db , _DDoc ) ->
138+ send_error (Req , {bad_request , " path not recognized" }).
139+
125140handle_cleanup_req (# httpd {method = 'POST' }= Req , # db {name = DbName }) ->
126141 ok = dreyfus_fabric_cleanup :go (DbName ),
127142 send_json (Req , 202 , {[{ok , true }]});
0 commit comments