Complete the GET handler. It would return some wrong codes before.

main
absc 2024-08-02 23:24:54 +02:00
parent f1ad05f789
commit 33cc07914d
1 changed files with 9 additions and 2 deletions

View File

@ -26,7 +26,8 @@ else is considered a bad request, apart from the obvious case of 500
-export([init/2, terminate/3, allowed_methods/2, -export([init/2, terminate/3, allowed_methods/2,
content_types_provided/2, known_methods/2, content_types_provided/2, known_methods/2,
resource_exists/2, send_body/2]). resource_exists/2, previously_existed/2,
moved_permanently/2, send_body/2]).
-include_lib("storage/include/storage.hrl"). -include_lib("storage/include/storage.hrl").
@ -41,7 +42,7 @@ allowed_methods(Req, State) ->
{[<<"GET">>], Req, State}. {[<<"GET">>], Req, State}.
content_types_provided(Req, State) -> content_types_provided(Req, State) ->
{[{{'_', '*'}, send_body}], Req, State}. {[{<<"*/*">>, send_body}], Req, State}.
known_methods(Req, State) -> known_methods(Req, State) ->
{[<<"GET">>], Req, State}. {[<<"GET">>], Req, State}.
@ -55,6 +56,12 @@ resource_exists(Req, State) ->
_ -> {false, Req, []} _ -> {false, Req, []}
end. end.
previously_existed(Req, _State) ->
{false, Req, []}.
moved_permanently(Req, State) ->
{false, Req, State}.
send_body(Req, Record) -> send_body(Req, Record) ->
{Record#object.value, Req, '_'}. {Record#object.value, Req, '_'}.