-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
112 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
hello world! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module AsyncResponse where | ||
|
||
import Prelude | ||
|
||
import Control.Monad.Eff.Console as Console | ||
import HTTPure as HTTPure | ||
import Node.Encoding as Encoding | ||
import Node.FS as FS | ||
import Node.FS.Aff as FSAff | ||
|
||
-- | Serve the example server on this port | ||
port :: Int | ||
port = 8088 | ||
|
||
-- | Shortcut for `show port` | ||
portS :: String | ||
portS = show port | ||
|
||
-- | The path to the file containing the response to send | ||
filePath :: String | ||
filePath = "./docs/Examples/AsyncResponse/Hello" | ||
|
||
-- | Say 'hello world!' when run | ||
sayHello :: forall e. HTTPure.Request -> HTTPure.ResponseM (fs :: FS.FS | e) | ||
sayHello _ = FSAff.readTextFile Encoding.UTF8 filePath >>= HTTPure.ok | ||
|
||
-- | Boot up the server | ||
main :: forall e. HTTPure.ServerM (console :: Console.CONSOLE, fs :: FS.FS | e) | ||
main = HTTPure.serve port sayHello do | ||
Console.log $ " ┌────────────────────────────────────────────┐" | ||
Console.log $ " │ Server now up on port " <> portS <> " │" | ||
Console.log $ " │ │" | ||
Console.log $ " │ To test, run: │" | ||
Console.log $ " │ > curl localhost:" <> portS <> " # => hello world! │" | ||
Console.log $ " └────────────────────────────────────────────┘" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Async Response Example | ||
|
||
This is a basic 'hello world' example, that responds by asynchronously reading a | ||
file off the filesystem. It simply returns 'hello world!' when making any | ||
request, but the 'hello world!' text is fetched by reading the contents of the | ||
file [Hello](./Hello). | ||
|
||
To run the example server, run: | ||
|
||
```bash | ||
make example EXAMPLE=AsyncResponse | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module HTTPure.HTTPureEffects | ||
( HTTPureEffects | ||
) where | ||
|
||
import Control.Monad.Eff.Exception as Exception | ||
import Control.Monad.ST as ST | ||
import Node.HTTP as HTTP | ||
|
||
-- | A row of types that are used by an HTTPure server. | ||
type HTTPureEffects e = | ||
( http :: HTTP.HTTP | ||
, st :: ST.ST String | ||
, exception :: Exception.EXCEPTION | ||
| e | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module HTTPure.HTTPureEffectsSpec where | ||
|
||
import Prelude | ||
|
||
import Test.Spec as Spec | ||
|
||
import HTTPure.SpecHelpers as SpecHelpers | ||
|
||
httpureEffectsSpec :: SpecHelpers.Test | ||
httpureEffectsSpec = Spec.describe "HTTPureEffects" do | ||
pure unit |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters