summaryrefslogtreecommitdiff
path: root/src/v1.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/v1.erl')
-rw-r--r--src/v1.erl22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/v1.erl b/src/v1.erl
index e066cdd..447b36e 100644
--- a/src/v1.erl
+++ b/src/v1.erl
@@ -5,7 +5,9 @@
-module(v1).
%% API (URL)
--export([request/3]).
+-export([request/4]).
+
+-define(APPURL_CT_V1, "ct/v1").
check_valid_sth() ->
case plop:sth() of
@@ -28,15 +30,15 @@ check_valid_sth() ->
end.
%% Public functions, i.e. part of URL.
-request(post, "ct/v1/add-chain", Input) ->
+request(post, ?APPURL_CT_V1, "add-chain", Input) ->
check_valid_sth(),
add_chain(Input, normal);
-request(post, "ct/v1/add-pre-chain", Input) ->
+request(post, ?APPURL_CT_V1, "add-pre-chain", Input) ->
check_valid_sth(),
add_chain(Input, precert);
-request(get, "ct/v1/get-sth", _Query) ->
+request(get, ?APPURL_CT_V1, "get-sth", _Query) ->
check_valid_sth(),
case plop:sth() of
noentry ->
@@ -46,7 +48,7 @@ request(get, "ct/v1/get-sth", _Query) ->
success(R)
end;
-request(get, "ct/v1/get-sth-consistency", Query) ->
+request(get, ?APPURL_CT_V1, "get-sth-consistency", Query) ->
check_valid_sth(),
case lists:sort(Query) of
[{"first", FirstInput}, {"second", SecondInput}] ->
@@ -65,7 +67,7 @@ request(get, "ct/v1/get-sth-consistency", Query) ->
_ -> err400("get-sth-consistency: bad input:", Query)
end;
-request(get, "ct/v1/get-proof-by-hash", Query) ->
+request(get, ?APPURL_CT_V1, "get-proof-by-hash", Query) ->
check_valid_sth(),
case lists:sort(Query) of
[{"hash", HashInput}, {"tree_size", TreeSizeInput}] ->
@@ -91,7 +93,7 @@ request(get, "ct/v1/get-proof-by-hash", Query) ->
_ -> err400("get-proof-by-hash: bad input:", Query)
end;
-request(get, "ct/v1/get-entries", Query) ->
+request(get, ?APPURL_CT_V1, "get-entries", Query) ->
check_valid_sth(),
case lists:sort(Query) of
[{"end", EndInput}, {"start", StartInput}] ->
@@ -105,7 +107,7 @@ request(get, "ct/v1/get-entries", Query) ->
_ -> err400("get-entries: bad input:", Query)
end;
-request(get, "ct/v1/get-entry-and-proof", Query) ->
+request(get, ?APPURL_CT_V1, "get-entry-and-proof", Query) ->
check_valid_sth(),
case lists:sort(Query) of
[{"leaf_index", IndexInput}, {"tree_size", TreeSizeInput}] ->
@@ -120,14 +122,14 @@ request(get, "ct/v1/get-entry-and-proof", Query) ->
_ -> err400("get-entry-and-proof: bad input:", Query)
end;
-request(get, "ct/v1/get-roots", _Query) ->
+request(get, ?APPURL_CT_V1, "get-roots", _Query) ->
check_valid_sth(),
R = [{certificates,
[base64:encode(Der) ||
Der <- catlfish:update_known_roots()]}],
success({R});
-request(_Method, _Path, _) ->
+request(_Method, _App, _Fun, _) ->
none.
%% Private functions.