As discuss, we should decouple the logic of request and back-end life cycle, the command APIs should return Accepted(202) or No Content(204).
for zookeeper example:
create zookeeper data: POST with payload, response created object
start zookeeper: PUT without payload, response httpcode=202
stop zookeeper: PUT without payload, response httpcode=202
delete zookeeper data: PUT without payload, response httpcode=204
get zookeeper information: GET without payload, response up-to-date object (include status)
/cc @wu87988622 @eechih @jackyoh @chia7712 @konekoya @vitojeng @DavidMi-1
have any suggestions?
I will fullfill the tasks after we have consensus
As discuss, we should decouple the logic of request and back-end life cycle, the command APIs should return Accepted(203) or No Content(204).
Accepted 應該是 202
200 OK, 201 Created, 204 No Content 是同一類型,代表伺服器成功處理了請求,已經有了結果(狀態),回應訊息應該要包含(或不包含)結果或狀態 --> Client 不用再次向 Server 請求最新訊息。
202 Accepted,代表伺服器只接受了請求,工作尚在處理中,尚未有結果(狀態) --> Client 應該要主動向 Server 請求最新訊息。
這兩類型,會決定 UI 要如何處理請求(後續)的動作。
200 OK, 201 Created, 204 No Content 是同一類型,代表伺服器成功處理了請求,已經有了結果(狀態),回應訊息應該要包含(或不包含)結果或狀態 --> Client 不用再次向 Server 請求最新訊息。
202 Accepted,代表伺服器只接受了請求,工作尚在處理中,尚未有結果(狀態) --> Client 應該要主動向 Server 請求最新訊息。
這兩類型,會決定 UI 要如何處理請求(後續)的動作。
以我們目前的設計來看,202似乎是不適合的?
start/stop用201有點怪 (因為不是建立物件),所以應回傳200?
我支持用202 accepted
目前帶有action效果的PUT中,雖然不是每個都是「非同步」,但為了統一介面,使用202可以給我們比較多的調整空間。(同步的操作改成非同步的格式很容易,非同步改同步就很難了)
目前帶有action效果的PUT中,雖然不是每個都是「非同步」,但為了統一介面,使用202可以給我們比較多的調整空間
+1
Thanks @oharastream/developer !
Since #1544 is still working on, I will separate these changes to #1544.
If you have any question, please move to #1544.
close this issue now.
Most helpful comment
200 OK, 201 Created, 204 No Content 是同一類型,代表伺服器成功處理了請求,已經有了結果(狀態),回應訊息應該要包含(或不包含)結果或狀態 --> Client 不用再次向 Server 請求最新訊息。
202 Accepted,代表伺服器只接受了請求,工作尚在處理中,尚未有結果(狀態) --> Client 應該要主動向 Server 請求最新訊息。
這兩類型,會決定 UI 要如何處理請求(後續)的動作。