on master help sign in
set content type correctly for deps-info.json
637a29dEvan Czaplicki
worker/src/Main.hs+9−2
@@ -7,6 +7,7 @@ module Main
7
7
8
8
9import Control.Monad (msum)
9import Control.Monad (msum)
10+import qualified Data.ByteString as BS
10import Snap.Core
11import Snap.Core
11import Snap.Http.Server
12import Snap.Http.Server
12
13
@@ -32,8 +33,7 @@ main =
32 , path "repl" $ Repl.endpoint rArtifacts
33 , path "repl" $ Repl.endpoint rArtifacts
33 , path "compile" $ Compile.endpoint cArtifacts
34 , path "compile" $ Compile.endpoint cArtifacts
34 , path "compile/errors.js" $ writeBS errorJS
35 , path "compile/errors.js" $ writeBS errorJS
35− , path "compile/deps-info.json" $
36+ , path "compile/deps-info.json" $ serveDepsInfo depsInfo
36− Cors.allow GET ["https://elm-lang.org"] (writeBS depsInfo)
37 , notFound
37 , notFound
38 ]
38 ]
39
39
@@ -54,3 +54,10 @@ notFound =
54 do modifyResponse $ setResponseStatus 404 "Not Found"
54 do modifyResponse $ setResponseStatus 404 "Not Found"
55 modifyResponse $ setContentType "text/html; charset=utf-8"
55 modifyResponse $ setContentType "text/html; charset=utf-8"
56 writeBuilder "Not Found"
56 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