@@ -21,6 +21,7 @@ import qualified Data.Aeson as A
21
21
import Data.Aeson ((.=) )
22
22
import Data.Bifunctor (first , second )
23
23
import qualified Data.ByteString.Lazy as BL
24
+ import Data.Default (def )
24
25
import Data.Function (on )
25
26
import Data.List (foldl' , nubBy )
26
27
import qualified Data.List.NonEmpty as NE
@@ -41,6 +42,7 @@ import qualified Language.PureScript.CoreFn as CF
41
42
import qualified Language.PureScript.Errors.JSON as P
42
43
import qualified Language.PureScript.Interactive as I
43
44
import qualified Language.PureScript.TypeChecker.TypeSearch as TS
45
+ import qualified Network.Wai.Handler.Warp as Warp
44
46
import System.Environment (getArgs )
45
47
import System.Exit (exitFailure )
46
48
import System.FilePath ((</>) )
@@ -89,7 +91,7 @@ server externs initNamesEnv initEnv port = do
89
91
Right _ ->
90
92
(return . Left . OtherError ) " The name of the main module should be Main."
91
93
92
- scotty port $ do
94
+ scottyOpts (getOpts port) $ do
93
95
get " /" $
94
96
Scotty. text " POST api.purescript.org/compile"
95
97
post " /compile" $ do
@@ -120,6 +122,14 @@ server externs initNamesEnv initEnv port = do
120
122
]
121
123
]
122
124
125
+ getOpts :: Int -> Scotty. Options
126
+ getOpts port = def
127
+ { settings =
128
+ Warp. setHost " 127.0.0.1"
129
+ $ Warp. setPort port
130
+ $ Warp. defaultSettings
131
+ }
132
+
123
133
lookupAllConstructors :: P. Environment -> P. SourceType -> [P. SourceType ]
124
134
lookupAllConstructors env = P. everywhereOnTypesM $ \ case
125
135
P. TypeConstructor ann (P. Qualified Nothing tyCon) -> P. TypeConstructor ann <$> lookupConstructor env tyCon
0 commit comments