diff --git a/docs/Examples/AsyncResponse/Main.purs b/docs/Examples/AsyncResponse/Main.purs index 8206939..79192b9 100644 --- a/docs/Examples/AsyncResponse/Main.purs +++ b/docs/Examples/AsyncResponse/Main.purs @@ -30,7 +30,7 @@ router { route: SayHello } = readTextFile UTF8 filePath >>= ok -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌────────────────────────────────────────────┐" diff --git a/docs/Examples/BinaryRequest/Main.purs b/docs/Examples/BinaryRequest/Main.purs index c58eb8a..bec340c 100644 --- a/docs/Examples/BinaryRequest/Main.purs +++ b/docs/Examples/BinaryRequest/Main.purs @@ -28,7 +28,7 @@ router { body } = toBuffer body >>= sha256sum >>> ok -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌─────────────────────────────────────────────────────────┐" diff --git a/docs/Examples/BinaryResponse/Main.purs b/docs/Examples/BinaryResponse/Main.purs index 79e910e..5c6072a 100644 --- a/docs/Examples/BinaryResponse/Main.purs +++ b/docs/Examples/BinaryResponse/Main.purs @@ -33,7 +33,7 @@ router = const $ readFile filePath >>= ok' responseHeaders -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌──────────────────────────────────────┐" diff --git a/docs/Examples/Chunked/Main.purs b/docs/Examples/Chunked/Main.purs index 85ffba2..53c1a83 100644 --- a/docs/Examples/Chunked/Main.purs +++ b/docs/Examples/Chunked/Main.purs @@ -34,7 +34,7 @@ router = const $ runScript "echo 'hello '; sleep 1; echo 'world!'" >>= ok -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌──────────────────────────────────────┐" diff --git a/docs/Examples/CustomStack/Main.purs b/docs/Examples/CustomStack/Main.purs index dd9388f..c73a6cc 100644 --- a/docs/Examples/CustomStack/Main.purs +++ b/docs/Examples/CustomStack/Main.purs @@ -42,7 +42,7 @@ sayHello _ = do -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router: readerMiddleware sayHello } + serve { hostname: "localhost", port: 8080, onStarted } { route, router: readerMiddleware sayHello } where onStarted = do log " ┌───────────────────────────────────────┐" diff --git a/docs/Examples/Headers/Main.purs b/docs/Examples/Headers/Main.purs index 4984a93..50457de 100644 --- a/docs/Examples/Headers/Main.purs +++ b/docs/Examples/Headers/Main.purs @@ -32,7 +32,7 @@ router { headers } = ok' responseHeaders $ headers !@ "X-Input" -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌──────────────────────────────────────────────┐" diff --git a/docs/Examples/HelloWorld/Main.purs b/docs/Examples/HelloWorld/Main.purs index e23ac41..d607c83 100644 --- a/docs/Examples/HelloWorld/Main.purs +++ b/docs/Examples/HelloWorld/Main.purs @@ -20,7 +20,7 @@ route = RD.root $ RG.sum -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router: const $ ok "hello world!" } + serve { hostname: "localhost", port: 8080, onStarted } { route, router: const $ ok "hello world!" } where onStarted = do log " ┌────────────────────────────────────────────┐" diff --git a/docs/Examples/JsonParsing/Main.purs b/docs/Examples/JsonParsing/Main.purs index 7b1c607..dad1e09 100644 --- a/docs/Examples/JsonParsing/Main.purs +++ b/docs/Examples/JsonParsing/Main.purs @@ -46,7 +46,7 @@ testEncoder = JsonEncoder $ \{ hello } -> "{\"hello\": \"" <> hello <> "\" }" -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where router { route: SayHello, method: Post, body } = usingCont do -- in your project you will want to use Argonaut.jsonDecoder from httpurple-argonaut diff --git a/docs/Examples/Middleware/Main.purs b/docs/Examples/Middleware/Main.purs index 70b4e8f..11c83f6 100644 --- a/docs/Examples/Middleware/Main.purs +++ b/docs/Examples/Middleware/Main.purs @@ -80,7 +80,7 @@ middlewareStack = loggingMiddleware <<< headerMiddleware <<< pathMiddleware -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route: middlewareRoute <+> sayHelloRoute, router: middlewareStack sayHello } + serve { hostname: "localhost", port: 8080, onStarted } { route: middlewareRoute <+> sayHelloRoute, router: middlewareStack sayHello } where onStarted = do log " ┌───────────────────────────────────────┐" diff --git a/docs/Examples/MultiRoute/Main.purs b/docs/Examples/MultiRoute/Main.purs index e8bb0b6..6a1ba71 100644 --- a/docs/Examples/MultiRoute/Main.purs +++ b/docs/Examples/MultiRoute/Main.purs @@ -29,7 +29,7 @@ router { route: GoodBye } = ok "goodbye" -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌────────────────────────────────┐" diff --git a/docs/Examples/PathSegments/Main.purs b/docs/Examples/PathSegments/Main.purs index 94e7b46..d6f2dc5 100644 --- a/docs/Examples/PathSegments/Main.purs +++ b/docs/Examples/PathSegments/Main.purs @@ -30,7 +30,7 @@ router { route: ManySegments elems } = ok $ show elems -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌───────────────────────────────────────────────┐" diff --git a/docs/Examples/Post/Main.purs b/docs/Examples/Post/Main.purs index 5a1374f..a360eb0 100644 --- a/docs/Examples/Post/Main.purs +++ b/docs/Examples/Post/Main.purs @@ -27,7 +27,7 @@ router _ = notFound -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted = do log " ┌───────────────────────────────────────────┐" diff --git a/docs/Examples/QueryParameters/Main.purs b/docs/Examples/QueryParameters/Main.purs index 9405602..01b4dd3 100644 --- a/docs/Examples/QueryParameters/Main.purs +++ b/docs/Examples/QueryParameters/Main.purs @@ -31,7 +31,7 @@ router _ = notFound -- | Boot up the server main :: ServerM main = - serve { port: 8080, onStarted } { route, router } + serve { hostname: "localhost", port: 8080, onStarted } { route, router } where onStarted :: Effect Unit onStarted = do diff --git a/docs/Examples/SSL/Main.purs b/docs/Examples/SSL/Main.purs index 02645ae..43299e6 100644 --- a/docs/Examples/SSL/Main.purs +++ b/docs/Examples/SSL/Main.purs @@ -35,7 +35,7 @@ sayHello _ = ok "hello world!" -- | Boot up the server main :: ServerM main = - serve { port: 8080, certFile: cert, keyFile: key, onStarted } { route, router: sayHello } + serve { hostname: "localhost", port: 8080, certFile: cert, keyFile: key, onStarted } { route, router: sayHello } where onStarted = do diff --git a/test/Test/HTTPurple/ServerSpec.purs b/test/Test/HTTPurple/ServerSpec.purs index 3576365..59e3e20 100644 --- a/test/Test/HTTPurple/ServerSpec.purs +++ b/test/Test/HTTPurple/ServerSpec.purs @@ -41,13 +41,13 @@ serveSpec :: Test serveSpec = describe "serve" do it "boots a server on the given port" do - close <- liftEffect $ serve { port: 8080 } { route, router: mockRouter } + close <- liftEffect $ serve { hostname: "localhost", port: 8080 } { route, router: mockRouter } out <- get 8080 empty "/test" liftEffect $ close $ pure unit out ?= "/test" it "responds with a 500 upon unhandled exceptions" do let router _ = throwError $ error "fail!" - close <- liftEffect $ serve { port: 8080 } { route, router } + close <- liftEffect $ serve { hostname: "localhost", port: 8080 } { route, router } status <- getStatus 8080 empty "/test" liftEffect $ close $ pure unit status ?= 500 @@ -70,14 +70,14 @@ serveSecureSpec = it "boots a server on the given port" do close <- liftEffect - $ serve { port: 8080, certFile: "./test/Mocks/Certificate.cer", keyFile: "./test/Mocks/Key.key" } { route, router: mockRouter } + $ serve { hostname: "localhost", port: 8080, certFile: "./test/Mocks/Certificate.cer", keyFile: "./test/Mocks/Key.key" } { route, router: mockRouter } out <- get' 8080 empty "/test" liftEffect $ close $ pure unit out ?= "/test" describe "with invalid key and cert files" do it "throws" do expectError $ liftEffect - $ serve { port: 8080, certFile: "", keyFile: "" } { route, router: mockRouter } + $ serve { hostname: "localhost", port: 8080, certFile: "", keyFile: "" } { route, router: mockRouter } serveSecure'Spec :: Test serveSecure'Spec =