{"id":20089128,"url":"https://github.com/jneira/wai-servlet","last_synced_at":"2025-07-05T09:05:09.623Z","repository":{"id":93765247,"uuid":"80696572","full_name":"jneira/wai-servlet","owner":"jneira","description":"Library to integrate eta wai applications with servlet api","archived":false,"fork":false,"pushed_at":"2019-01-09T09:48:34.000Z","size":153,"stargazers_count":18,"open_issues_count":4,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-05T09:05:08.490Z","etag":null,"topics":["eta-lang","haskell","interop","java","servlet","wai"],"latest_commit_sha":null,"homepage":"","language":"Haskell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jneira.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-02-02T05:30:43.000Z","updated_at":"2023-09-08T17:20:21.000Z","dependencies_parsed_at":"2023-03-04T04:30:19.096Z","dependency_job_id":null,"html_url":"https://github.com/jneira/wai-servlet","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/jneira/wai-servlet","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jneira%2Fwai-servlet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jneira%2Fwai-servlet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jneira%2Fwai-servlet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jneira%2Fwai-servlet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jneira","download_url":"https://codeload.github.com/jneira/wai-servlet/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jneira%2Fwai-servlet/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263715326,"owners_count":23500241,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["eta-lang","haskell","interop","java","servlet","wai"],"created_at":"2024-11-13T16:16:34.118Z","updated_at":"2025-07-05T09:05:09.615Z","avatar_url":"https://github.com/jneira.png","language":"Haskell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wai-servlet\n\n[![CircleCI](https://circleci.com/gh/eta-lang/wai-servlet.svg?style=svg)](https://circleci.com/gh/eta-lang/wai-servlet)\n\nLibrary to integrate [eta](http://eta-lang.org) [wai](https://github.com/yesodweb/wai) applications with the [servlet api](http://docs.oracle.com/javaee/7/api/javax/servlet/package-summary.html)\n\n## Getting Started\n* Visit the [Getting Started](https://eta-lang.org/docs/eta-concepts/getting-started/install-eta) eta instructions to build and install the library and the examples\n* 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.\n* 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.\n\n### Running an application in a embedded servlet container\n\n* You need to install and set the [wai-servlet-jetty-adapter](https://github.com/jneira/wai-servlet-handler-jetty) package as a dependency. Currently is the unique adapter implemented for wai-servlet.\n* 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:\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\nimport Network.HTTP.Types                 (status200)\nimport Network.Wai\nimport Network.Wai.Servlet\nimport Network.Wai.Servlet.Handler.Jetty\n\nappSimple :: Application\nappSimple _ respond = respond $\n   responseLBS status200 [(\"Content-Type\", \"text/plain\")] \"Hello World\"\n\nmain = run 3000 appSimple\n```\n\n### Generating a war to be deployed in a servlet container\n* 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).\n* The main function to generate the servlet is `Network.Wai.Servlet.makeServiceMethod` for example:\n```haskell\n{-# LANGUAGE OverloadedStrings #-}\nimport Java\nimport Network.Wai\nimport Network.HTTP.Types                 (status200)\nimport Network.Wai.Servlet\n\nappSimple :: Application\nappSimple _ respond = respond $\n   responseLBS status200 [(\"Content-Type\", \"text/plain\")] \"Hello World\"\n\nservSimple :: DefaultWaiServletApplication\nservSimple = makeServiceMethod appSimple\n\nforeign export java \"service\" servSimple :: DefaultWaiServletApplication\n```\n* This code will generate a `network.wai.servlet.DefaultWaiServlet` java class that extends `javax.servlet.GenericServlet` suitable to use in a standard war file\n* To generate the war you have to create the standard directory structure:\n  * webApp\n    * static resources (jsp,html,etc)\n    * META-INF\n    * WEB-INF\n      * web.xml (required if you use servlets)\n      * classes\n      * lib\n        * wai-servlet-app.jar\n* The web.xml for the default wai servlet could be\n```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cweb-app id=\"WebApp_ID\" version=\"2.5\" xmlns=\"http://java.sun.com/xml/ns/javaee\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd\"\u003e\n\t\u003cdisplay-name\u003ewai-servlet-test\u003c/display-name\u003e\n\n\t\u003cservlet\u003e\n\t\t\u003cservlet-name\u003ewai-servlet\u003c/servlet-name\u003e\n\t\t\u003cservlet-class\u003enetwork.wai.servlet.DefaultWaiServlet\u003c/servlet-class\u003e\n\t\u003c/servlet\u003e\n\t\n\t\u003cservlet-mapping\u003e\n\t\t\u003cservlet-name\u003ewai-servlet\u003c/servlet-name\u003e\n\t\t\u003curl-pattern\u003e/\u003c/url-pattern\u003e\n\t\u003c/servlet-mapping\u003e\n\t\n\u003c/web-app\u003e\n```\n* 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.)\n* With the war file you can deploy your wai application in a servlet container:\n  * tomcat: https://tomcat.apache.org/tomcat-8.0-doc/deployer-howto.html\n    * the easier way is to place the war file in $TOMCAT_INSTALL_DIR$/webapps\n  * jetty: https://www.eclipse.org/jetty/documentation/9.4.x/configuring-deployment.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjneira%2Fwai-servlet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjneira%2Fwai-servlet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjneira%2Fwai-servlet/lists"}