fix(gw): return HTTP 400 for unimplemented handle call
This commit is contained in:
parent
578a231a8d
commit
465f71180a
|
@ -197,6 +197,10 @@ subscriptions(get, #{
|
||||||
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
|
case emqx_gateway_http:list_client_subscriptions(GwName, ClientId) of
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
return_http_error(404, "client process not found");
|
return_http_error(404, "client process not found");
|
||||||
|
{error, ignored} ->
|
||||||
|
return_http_error(
|
||||||
|
400, "get subscriptions failed: unsupported"
|
||||||
|
);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return_http_error(400, Reason);
|
return_http_error(400, Reason);
|
||||||
{ok, Subs} ->
|
{ok, Subs} ->
|
||||||
|
@ -222,7 +226,13 @@ subscriptions(post, #{
|
||||||
)
|
)
|
||||||
of
|
of
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
return_http_error(404, "client process not found");
|
return_http_error(
|
||||||
|
404, "client process not found"
|
||||||
|
);
|
||||||
|
{error, ignored} ->
|
||||||
|
return_http_error(
|
||||||
|
400, "subscribe failed: unsupported"
|
||||||
|
);
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
return_http_error(400, Reason);
|
return_http_error(400, Reason);
|
||||||
{ok, {NTopic, NSubOpts}} ->
|
{ok, {NTopic, NSubOpts}} ->
|
||||||
|
@ -241,8 +251,14 @@ subscriptions(delete, #{
|
||||||
with_gateway(Name0, fun(GwName, _) ->
|
with_gateway(Name0, fun(GwName, _) ->
|
||||||
case lookup_topic(GwName, ClientId, Topic) of
|
case lookup_topic(GwName, ClientId, Topic) of
|
||||||
{ok, _} ->
|
{ok, _} ->
|
||||||
_ = emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic),
|
case emqx_gateway_http:client_unsubscribe(GwName, ClientId, Topic) of
|
||||||
{204};
|
{error, ignored} ->
|
||||||
|
return_http_error(
|
||||||
|
400, "unsubscribe failed: unsupported"
|
||||||
|
);
|
||||||
|
_ ->
|
||||||
|
{204}
|
||||||
|
end;
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
return_http_error(404, "Resource not found")
|
return_http_error(404, "Resource not found")
|
||||||
end
|
end
|
||||||
|
|
|
@ -378,6 +378,8 @@ client_call(GwName, ClientId, Req) ->
|
||||||
of
|
of
|
||||||
undefined ->
|
undefined ->
|
||||||
{error, not_found};
|
{error, not_found};
|
||||||
|
ignored ->
|
||||||
|
{error, ignored};
|
||||||
Res ->
|
Res ->
|
||||||
Res
|
Res
|
||||||
catch
|
catch
|
||||||
|
|
Loading…
Reference in New Issue