fix bool, and route

This commit is contained in:
Ery Lee 2015-01-18 16:22:46 +08:00
parent e7a4be9669
commit 0b09d8a695
1 changed files with 5 additions and 6 deletions

View File

@ -50,12 +50,11 @@ handle('POST', "/mqtt/publish", Req) ->
Message = list_to_binary(get_value("message", Params)),
case {validate(qos, Qos), validate(topic, Topic)} of
{true, true} ->
emqtt_pubsub:publish(#mqtt_message {
qos = Qos,
retain = bool(Retain),
topic = Topic,
payload = Message
}),
emqtt_router:route(
#mqtt_message { qos = Qos,
retain = Retain,
topic = Topic,
payload = Message }),
Req:ok({"text/plan", <<"ok">>});
{false, _} ->
Req:respond({400, [], <<"Bad QoS">>});