A WAI Application connects a web server implementation to request-handling code. It receives a request and response callback, computes a response, and invokes the callback. section 17.2.1
In a Servant server, an Application is produced from an API description and its handlers:
- Use serve with a Proxy for the API and the implemented Server to produce an Application. section 17.2.1
- Wrap an Application with Middleware when adding behavior without changing the Servant API type. section 17.2.2
Creating and running an application
mkApiServer :: Connection -> Application mkApiServer = serve todoApi . mkTodoApiServer main :: IO () main = do let port = 9001 withConnection ":memory:" $ \dbConn -> do setupDb dbConn run port (mkApiServer dbConn) This starts a Servant todo-list API on port 9001, where requests such as GET /entries and POST /add can be tested. section 17.2.1
