From d9f78c2543200114ca3d35b8cf855f4d39da33c3 Mon Sep 17 00:00:00 2001 From: Geoff Cant Date: Fri, 13 Apr 2012 17:25:53 -0700 Subject: [PATCH] Use logplex_api:channel_info(Vsn,ChannelId). Also responds with a 404 for channels that can't be found. --- src/logplex_api.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/logplex_api.erl b/src/logplex_api.erl index f0be484e..5fc11380 100644 --- a/src/logplex_api.erl +++ b/src/logplex_api.erl @@ -132,10 +132,11 @@ handlers() -> %% V2 {['GET', "^/v2/channels/(\\d+)$"], fun(Req, [ChannelId]) -> authorize(Req), - Info = logplex_channel:info_v2(list_to_integer(ChannelId)), - not is_list(Info) andalso exit({expected_list, Info}), - - {200, iolist_to_binary(mochijson2:encode({struct, Info}))} + case channel_info(api_v2, list_to_integer(ChannelId)) of + not_found -> not_found_json(); + Info -> + {200, iolist_to_binary(mochijson2:encode({struct, Info}))} + end end}, {['DELETE', "^/channels/(\\d+)$"], fun(Req, [ChannelId]) ->