phantasy-http-server
Version:
An HTTP server built on Phantasy
73 lines (45 loc) • 1.4 kB
Markdown
# phantasy-http-server
[](https://travis-ci.org/tkuminecz/phantasy-http-server)
HTTP server library built with [`Phantasy`](https://github.com/tkuminecz/phantasy)
## Server
### `createServer`
```
:: (() -> EffTask fxa e) -> RequestHandler e fxb -> HttpServer fxa fxb e
```
Creates a new `HttpServer`.
### `startServer`
```
:: HttpServerOpts -> HttpServer fxa fxb e -> EffTask (fxa & fxb) void Error
```
Takes an options object and returns an `EffTask` that succeeds with the start of the server or fails with an `Error`.
## Router
### `get`
```
:: string -> RouteHandler e fx p q -> Route e fx p q
```
Creates a GET route that matches the given path.
### `post`
```
:: string -> RouteHandler e fx p q -> Route e fx p q
```
Creates a POST route that matches the given path.
### `put`
```
:: string -> RouteHandler e fx p q -> Route e fx p q
```
Creates a PUT route that matches the given path.
### `del`
```
:: string -> RouteHandler e fx p q -> Route e fx p q
```
Creates a DELETE route that matches the given path.
### `mergeRoutes`
```
:: Array (Routable e fx) -> Routable e fx
```
Takes an array of `Routable` objects and merges them into a single `Routable` object.
### `dispatch`
```
:: Routable e fx -> RequestHandler e fx
```
Takes a `Routable` and returns a `RequestHandler`.