From d9f14dacaf8a77f27f9733054dd2d724cc684ec7 Mon Sep 17 00:00:00 2001 From: turtled Date: Mon, 25 Sep 2017 14:59:58 +0800 Subject: [PATCH] Fix dashboard not showing data bug --- src/emqttd_http.erl | 14 +++++++------- src/emqttd_rest_api.erl | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/emqttd_http.erl b/src/emqttd_http.erl index bc5ba764d..f62329ada 100644 --- a/src/emqttd_http.erl +++ b/src/emqttd_http.erl @@ -26,7 +26,7 @@ -import(proplists, [get_value/2, get_value/3]). --export([http_handler/0, handle_request/2, http_api/0]). +-export([http_handler/0, handle_request/2, http_api/0, inner_handle_request/2]). -include("emqttd_internal.hrl"). @@ -54,14 +54,14 @@ handle_request(Req, State) -> "/api/v2/auth" -> handle_request(Path, Req, State); _ -> - Host = Req:get_header_value("Host"), - [_, Port] = string:tokens(Host, ":"), - case Port of - "18083" -> handle_request(Path, Req, State); - _ -> if_authorized(Req, fun() -> handle_request(Path, Req, State) end) - end + if_authorized(Req, fun() -> handle_request(Path, Req, State) end) end. +inner_handle_request(Req, State) -> + Path = Req:get(path), + handle_request(Path, Req, State). + + handle_request("/api/v2/" ++ Url, Req, #state{dispatch = Dispatch}) -> Dispatch(Req, Url); diff --git a/src/emqttd_rest_api.erl b/src/emqttd_rest_api.erl index d0ab6a855..baa056b81 100644 --- a/src/emqttd_rest_api.erl +++ b/src/emqttd_rest_api.erl @@ -25,7 +25,7 @@ -http_api({"^nodes/(.+?)/clients/(.+?)/?$", 'GET',client_list, []}). -http_api({"^clients/(.+?)/?$", 'GET', client, []}). -http_api({"^clients/(.+?)/?$", 'DELETE', kick_client, []}). --http_api({"^clients/(.+?)/clean_acl_cache?$", 'DELETE', clean_acl_cache, [{<<"topic">>, binary}]}). +-http_api({"^clients/(.+?)/clean_acl_cache?$", 'PUT', clean_acl_cache, [{<<"topic">>, binary}]}). -http_api({"^routes?$", 'GET', route_list, []}). -http_api({"^routes/(.+?)/?$", 'GET', route, []}).