Sfoglia il codice sorgente

fix(emqx_gateway): return 204 for lwm2m client posts

Change the return for lwm2m client API posts from 200 to 204 since
they contain no content.
Erik Timan 3 anni fa
parent
commit
a8c9d02871
1 ha cambiato i file con 4 aggiunte e 4 eliminazioni
  1. 4 4
      apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl

+ 4 - 4
apps/emqx_gateway/src/lwm2m/emqx_lwm2m_api.erl

@@ -81,7 +81,7 @@ schema(?PATH("/observe")) ->
             ],
             ],
             'requestBody' => [],
             'requestBody' => [],
             responses => #{
             responses => #{
-                200 => <<"No Content">>,
+                204 => <<"No Content">>,
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
             }
             }
         }
         }
@@ -98,7 +98,7 @@ schema(?PATH("/read")) ->
                 {path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})}
                 {path, mk(binary(), #{in => query, required => true, example => "/3/0/7"})}
             ],
             ],
             responses => #{
             responses => #{
-                200 => <<"No Content">>,
+                204 => <<"No Content">>,
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"clientid not found">>)
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"clientid not found">>)
             }
             }
         }
         }
@@ -121,7 +121,7 @@ schema(?PATH("/write")) ->
                 {value, mk(binary(), #{in => query, required => true, example => 123})}
                 {value, mk(binary(), #{in => query, required => true, example => 123})}
             ],
             ],
             responses => #{
             responses => #{
-                200 => <<"No Content">>,
+                204 => <<"No Content">>,
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
                 404 => error_codes(['CLIENT_NOT_FOUND'], <<"Clientid not found">>)
             }
             }
         }
         }
@@ -275,7 +275,7 @@ send_cmd(ClientId, Cmd) ->
     case emqx_gateway_cm_registry:lookup_channels(lwm2m, ClientId) of
     case emqx_gateway_cm_registry:lookup_channels(lwm2m, ClientId) of
         [Channel | _] ->
         [Channel | _] ->
             ok = emqx_lwm2m_channel:send_cmd(Channel, Cmd),
             ok = emqx_lwm2m_channel:send_cmd(Channel, Cmd),
-            {200};
+            {204};
         _ ->
         _ ->
             {404, #{code => 'CLIENT_NOT_FOUND'}}
             {404, #{code => 'CLIENT_NOT_FOUND'}}
     end.
     end.