update erlang server samples

This commit is contained in:
William Cheng 2021-06-19 10:50:52 +08:00
parent 513e242a3e
commit 70fb429c98
5 changed files with 8 additions and 3 deletions

View File

@ -6,8 +6,7 @@
-type handler_response() ::{
Status :: cowboy:http_status(),
Headers :: cowboy:http_headers(),
Body :: #{}
}.
Body :: jsx:json_term()}.
-export_type([handler_response/0]).

View File

@ -475,5 +475,7 @@ validate_headers(_, Req) -> {true, Req}.
prepare_body(204, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(304, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(_Code, Body) ->
jsx:encode(Body).

View File

@ -64,4 +64,4 @@ get_default_opts(LogicHandler) ->
#{env => get_default_dispatch(LogicHandler)}.
store_key(Key, Value, Opts) ->
lists:keystore(Key, 1, Opts, {Key, Value}).
maps:put(Key, Value, Opts).

View File

@ -270,5 +270,7 @@ validate_headers(_, Req) -> {true, Req}.
prepare_body(204, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(304, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(_Code, Body) ->
jsx:encode(Body).

View File

@ -437,5 +437,7 @@ validate_headers(_, Req) -> {true, Req}.
prepare_body(204, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(304, Body) when map_size(Body) == 0; length(Body) == 0 ->
<<>>;
prepare_body(_Code, Body) ->
jsx:encode(Body).