summaryrefslogtreecommitdiff
path: root/src/v1.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/v1.erl')
-rw-r--r--src/v1.erl16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/v1.erl b/src/v1.erl
index e672182..e2cadb3 100644
--- a/src/v1.erl
+++ b/src/v1.erl
@@ -15,8 +15,13 @@ request(post, "ct/v1/add-pre-chain", Input) ->
add_chain(Input, precert);
request(get, "ct/v1/get-sth", _Query) ->
- R = plop:sth(),
- success(R);
+ case plop:sth() of
+ noentry ->
+ lager:error("No valid STH found"),
+ internalerror("No valid STH found");
+ R ->
+ success(R)
+ end;
request(get, "ct/v1/get-sth-consistency", Query) ->
case lists:sort(Query) of
@@ -109,6 +114,13 @@ html(Text, Input) ->
success(Data) ->
{200, [{"Content-Type", "text/json"}], mochijson2:encode(Data)}.
+internalerror(Text) ->
+ {500, [{"Content-Type", "text/html"}],
+ io_lib:format(
+ "<html><body><p>~n" ++
+ "~s~n" ++
+ "</body></html>~n", [Text])}.
+
-spec add_chain(any(), normal|precert) -> any().
add_chain(Input, Type) ->
case (catch mochijson2:decode(Input)) of