Fix some bad docs

This commit is contained in:
Connor Prussin 2018-07-08 16:28:59 -07:00
parent 8badd62b3e
commit 12a6f36303
No known key found for this signature in database
GPG Key ID: C72452E036D53A6A
4 changed files with 19 additions and 19 deletions

View File

@ -39,7 +39,7 @@ module Main where
import Prelude (($))
import Control.Monad.Eff.Console as Console
import Effect.Console as Console
import HTTPure as HTTPure
main :: HTTPure.ServerM (console :: Console.CONSOLE)

View File

@ -5,11 +5,12 @@ This guide is a brief overview of the basics of creating a HTTPure server.
## Creating a Server
To create a server, use `HTTPure.serve` (no SSL) or `HTTPure.serveSecure` (SSL).
Both of these functions take a port number, a router function, and an `Eff` that
will run once the server has booted. The signature of the router function is:
Both of these functions take a port number, a router function, and an `Effect`
that will run once the server has booted. The signature of the router function
is:
```purescript
forall e. HTTPure.Request -> HTTPure.ResponseM e
HTTPure.Request -> HTTPure.ResponseM
```
For more details on routing, see the [Routing guide](./Routing.md). For more
@ -22,7 +23,7 @@ guide](./Middleware.md).
You can create an HTTPure server without SSL using `HTTPure.serve`:
```purescript
main :: forall e. HTTPure.ServerM (console :: Console.CONSOLE | e)
main :: HTTPure.ServerM
main = HTTPure.serve 8080 router $ Console.log "Server up"
```
@ -33,7 +34,7 @@ You can also create a server using a custom
`[HTTP.ListenOptions](http://bit.ly/2G42rLd)` value:
```purescript
main :: forall e. HTTPure.ServerM (console :: Console.CONSOLE | e)
main :: HTTPure.ServerM
main = HTTPure.serve' customOptions router $ Console.log "Server up"
```
@ -44,7 +45,7 @@ has the same signature as `HTTPure.serve` except that it additionally takes a
path to a cert file and a path to a key file after the port number:
```purescript
main :: forall e. HTTPure.SecureServerM (console :: Console.CONSOLE | e)
main :: HTTPure.ServerM
main =
HTTPure.serveSecure 8080 "./Certificate.cer" "./Key.key" router $
Console.log "Server up"
@ -58,7 +59,8 @@ You can also create a server using a
[HTTPS.SSLOptions](http://bit.ly/2G3Aljr)`:
```purescript
main :: forall e. HTTPure.SecureServerM (console :: Console.CONSOLE | e)
main :: HTTPure.ServerM
main =
HTTPure.serveSecure' customSSLOptions customOptions router $
Console.log "Server up"
```

View File

@ -14,9 +14,7 @@ build, compose, and consume different types of middleware.
A middleware is a function with the signature:
```purescript
forall e. (HTTPure.Request -> HTTPure.ResponseM e) ->
HTTPure.Request ->
HTTPure.ResponseM e
(HTTPure.Request -> HTTPure.ResponseM) -> HTTPure.Request -> HTTPure.ResponseM
```
Note that the first argument is just the signature for a router function. So
@ -89,9 +87,9 @@ In other words, say you have the following HTTPure server:
```purescript
middleware letter router request = do
EffClass.liftEff $ Console.log $ "Starting Middleware " <> letter
EffectClass.liftEffect $ Console.log $ "Starting Middleware " <> letter
response <- router request
EffClass.liftEff $ Console.log $ "Ending Middleware " <> letter
EffectClass.liftEffect $ Console.log $ "Ending Middleware " <> letter
pure response
main = HTTPure.serve port composedRouter $ Console.log "Server is up!"

View File

@ -12,7 +12,7 @@ The router function is called for each inbound request to the HTTPure server.
Its signature is:
```purescript
forall e. HTTPure.Request -> HTTPure.ResponseM e
HTTPure.Request -> HTTPure.ResponseM
```
So in HTTPure, routing is handled simply by the router being a pure function
@ -41,12 +41,12 @@ a `Record` type that contains the following fields:
- `path` - An `Array` of `String` path segments. A path segment is a nonempty
string separated by a `"/"`. Empty segments are stripped out when HTTPure
creates the `HTTPure.Request` record.
- `query` - A `StrMap` of `String` values. Note that if you have any query
- `query` - An `Object` of `String` values. Note that if you have any query
parameters without values (for instance, a URL like `/foo?bar`), then the
value in the `StrMap` for that query parameter will be the empty `String`
value in the `Object` for that query parameter will be the empty `String`
(`""`).
- `headers` - A `HTTPure.Headers` object. The `HTTPure.Headers` newtype wraps
the `StrMap String` type and provides some typeclass instances that make more
the `Object String` type and provides some typeclass instances that make more
sense when working with HTTP headers.
- `body` - A `String` containing the contents of the request body, or an empty
`String` if none was provided.
@ -67,8 +67,8 @@ There are three instances defined in HTTPure:
`Array.index`. Because the path is represented as an `Array` of `Strings`,
this can be used to retrieve the nth path segment by doing something like
`request.path !! n`.
2. `Lookup (StrMap t) String t` - In this instance, `HTTPure.lookup` is a
flipped version of `StrMap.lookup`. Because the query is a `StrMap String`,
2. `Lookup (Object t) String t` - In this instance, `HTTPure.lookup` is a
flipped version of `Object.lookup`. Because the query is a `Object String`,
this instance can be used to retrieve the value of a query parameter by name,
by doing something like `request.query !! "someparam"`.
3. `Lookup Headers String String` - This is similar to the example in #2, except