summaryrefslogtreecommitdiff
path: root/src/endpoints.sml
diff options
context:
space:
mode:
authorGravatar Artyom Shalkhakov <artyom.shalkhakov@gmail.com>2019-01-12 16:20:14 +0200
committerGravatar Artyom Shalkhakov <artyom.shalkhakov@gmail.com>2019-01-12 16:20:14 +0200
commitba1871b3b9cc669c43420f993719690b45326e2f (patch)
treedb204c53b57326b23014674b90f7ac21d80a3430 /src/endpoints.sml
parentdb68fd7f8dd17fda410ea06e7076e11ee2c57afc (diff)
Including app.js in output of endpoints
Diffstat (limited to 'src/endpoints.sml')
-rw-r--r--src/endpoints.sml25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/endpoints.sml b/src/endpoints.sml
index bb0b1d66..5699f319 100644
--- a/src/endpoints.sml
+++ b/src/endpoints.sml
@@ -59,7 +59,14 @@ fun p_report {Endpoints = el} =
p_list_sep (box [string ",", newline]) p_endpoint el,
string "]}"]
-fun summarize file =
+val endpoints = ref ([] : endpoint list)
+val jsFile = ref (NONE : string option)
+
+fun setJavaScript x = jsFile := SOME x
+
+fun reset () = (endpoints := []; jsFile := NONE)
+
+fun collect file =
let
fun exportKindToMethod (Link _) = GET
| exportKindToMethod (Action _) = POST
@@ -75,6 +82,8 @@ fun summarize file =
| _ => st
end
+ val () = reset ()
+
val (decls, _) = file
val ep = foldl decl [] decls
@@ -88,6 +97,20 @@ fun summarize file =
val ep = foldl jsfile ep (Settings.listJsFiles ())
in
+ endpoints := ep;
+ file
+ end
+
+fun summarize () =
+ let
+ val ep = !endpoints
+ val js = !jsFile
+ val ep =
+ case js of
+ NONE => ep
+ | SOME js =>
+ {Method = GET, Url = js, LastModified = NONE, ContentType = SOME "text/javascript"} :: ep
+ in
{Endpoints = ep}
end