@@ -7,6 +7,7 @@ module Main
77
88
99import Control.Monad (msum)
10+import qualified Data.ByteString as BS
1011import Snap.Core
1112import Snap.Http.Server
1213
@@ -32,8 +33,7 @@ main =
3233 , path "repl" $ Repl.endpoint rArtifacts
3334 , path "compile" $ Compile.endpoint cArtifacts
3435 , path "compile/errors.js" $ writeBS errorJS
35− , path "compile/deps-info.json" $
36− Cors.allow GET ["https://elm-lang.org"] (writeBS depsInfo)
36+ , path "compile/deps-info.json" $ serveDepsInfo depsInfo
3737 , notFound
3838 ]
3939
@@ -54,3 +54,10 @@ notFound =
5454 do modifyResponse $ setResponseStatus 404 "Not Found"
5555 modifyResponse $ setContentType "text/html; charset=utf-8"
5656 writeBuilder "Not Found"
57+
58+
59+serveDepsInfo :: BS.ByteString -> Snap ()
60+serveDepsInfo json =
61+ Cors.allow GET ["https://elm-lang.org"] $
62+ do modifyResponse $ setContentType "application/json"
63+ writeBS json