Skip to content

Commit 4fb7693

Browse files
committed
Update docs with the option to run in an embedded server
1 parent 08ea0df commit 4fb7693

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,29 @@ Library to integrate [eta](http://eta-lang.org) [wai](https://github.com/yesodwe
33

44
## Getting Started
55
* Visit the [Getting Started](http://eta-lang.org/docs/html/getting-started.html) eta instructions to build and install the library and the examples
6-
* In app/Main.hs you can find some examples of wai applications and how to generate a servlet class that can be deployed in your favorite servlet container
6+
* In [src/Network/Wai/Servlet/Examples.hs](https://github.com/jneira/wai-servlet/blob/master/src/Network/Wai/Servlet/Examples.hs) you can find some examples of wai applications and code to generate a servlet class that can be deployed in your favorite servlet container.
7+
* There are two options to deploy wai-servlet apps: generating a war file to be deployed in a servlet container or run it directly in a embedded one; this is the way more similar to use [wai warp](https://github.com/yesodweb/wai/tree/master/warp) for haskell wai applications.
8+
9+
### Running an application in a embedded servlet container
10+
11+
* You need to install and set the [wai-servlet-jetty-adapter](http://github/jneira/wai-servlet-jetty-adapter) package as a dependency. Currently is the unique adapter implemented for wai-servlet.
12+
* You have to import the module `Network.Wai.Servlet.Handler.Jetty` with the `run` function and call it with the port server and your application:
13+
```haskell
14+
{-# LANGUAGE OverloadedStrings #-}
15+
import Network.HTTP.Types (status200)
16+
import Network.Wai
17+
import Network.Wai.Servlet
18+
import Network.Wai.Servlet.Handler.Jetty
19+
20+
appSimple :: Application
21+
appSimple _ respond = respond $
22+
responseLBS status200 [("Content-Type", "text/plain")] "Hello World"
23+
24+
main = run 3000 appSimple
25+
```
26+
27+
### Generating a war to be deployed in a servlet container
28+
* This option supposes some manual steps. There is plans to make etlas build automatically a war file, tracked in [this issue](https://github.com/typelead/eta/issues/265).
729
* The main function to generate the servlet is `Network.Wai.Servlet.makeServiceMethod` for example:
830
```haskell
931
{-# LANGUAGE OverloadedStrings #-}
@@ -49,7 +71,7 @@ foreign export java "service" servSimple :: DefaultWaiServletApplication
4971

5072
</web-app>
5173
```
52-
* You have to place the jar or jars generated by epm in WEB-INF/lib and package the structure in a war file (using jar tool f.e.)
74+
* You have to place the jar or jars generated by etlas in WEB-INF/lib and package the structure in a war file (using jar tool f.e.)
5375
* With the war file you can deploy your wai application in a servlet container:
5476
* tomcat: https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html
5577
* the easier way is to place the war file in $TOMCAT_INSTALL_DIR$/webapps

0 commit comments

Comments
 (0)