Questions tagged [haskell-wai]

The wai package provides a common protocol for the communication between Haskell web applications and web servers.

The wai package provides a common protocol for the communication between Haskell web applications and web servers.

GitHub Repo: https://github.com/yesodweb/wai

Source: http://hackage.haskell.org/package/wai

73 questions
1
vote
2 answers

How do I QuickCheck a Servant Application that is constructed from an IO?

I am writing an API server using Servant. The server includes persistent state. I would like to use QuickCheck to write tests for the server. The implementation of various endpoints that make up the Servant Application require a database value. …
Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
1
vote
1 answer

Setup Wai Middleware request logger to drop (not log) some requests

I have an app where the Nginx reverse proxy is making a lot of requests to my health endpoint. I'd like to not log these at all so my output logs are smaller. I'm also logging everything as JSON using Network.Wai.Middleware.RequestLogger.JSON, which…
erewok
  • 7,555
  • 3
  • 33
  • 45
1
vote
0 answers

How to store values generated from middleware and retrieve them from routes

I have a wai middleware that produces two values: A request id generated randomly for each request A User from a request to another service. Here is the code: addRequestIdToRequestHeader' :: Application -> Application addRequestIdToRequestHeader'…
Leo Zhang
  • 3,040
  • 3
  • 24
  • 38
1
vote
1 answer

How do I set a cookie with Scotty / wai?

I've browsed the Scotty documentation but I only see the ability to set an HTTP header which seem a bit low level. Is there a more elegant way to achieve this? Third party libraries? From what I can find, a solution would be to use mapHeader from…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1
vote
1 answer

Haskell WARP/WAI server fails to respond to AJAX calls from Android embedded WebView

UPDATE 3 When hitting the endpoint http://httpbin.org/user-agent, the request returns successfully. So something is wrong with my Haskell Warp+WAI application server. Any ideas what could make a server API call work for most browsers, but not for…
1
vote
1 answer

Capturing parameters from a POST request in Spock

In the documentation of Spock, here https://www.spock.li/2015/04/19/type-safe_routing.html, it only describes how to capture parameters from a get request. I need to capture ones from a post. How can I do that?
Jodimoro
  • 4,355
  • 3
  • 11
  • 18
1
vote
1 answer

Creating a route for static assets or images in Hasekll Spock

I have this basic Spock application taken from its website: main :: IO () main = do ref <- newIORef 0 spockCfg <- defaultSpockCfg EmptySession PCNoDatabase (DummyAppState ref) runSpock 8080 (spock spockCfg app) app :: SpockM ()…
user7905648
  • 117
  • 6
1
vote
1 answer

How to server a folder of images/css/js in Wai/Warp?

I have this simple Wai/Warp application app :: Wai.Application app req respond = respond $ case Wai.rawPathInfo req of "/" -> Wai.responseFile status200 [("Content-Type", "text/html")] "views/index.html" Nothing _ -> notFound notFound ::…
user7905648
  • 117
  • 6
1
vote
1 answer

Using ajax in Servant

I use Haskell with servant-0.7.1 fo realisation server.Below is my source code: type UserRestAPI = "rest" :> "users" :> Get '[JSON] [User] :<|> "rest" :> "user" :> ReqBody '[JSON] User :> Post '[PlainText] Text serverUserRestAPI ::…
QSpider
  • 537
  • 2
  • 10
1
vote
1 answer

Unable to do pattern matching on Word8

In my Servant/Wai app I want to redict all the requests from "domain.com" to "www.domain.com" {-# LANGUAGE OverloadedStrings #-} --....... app :: Application app req respond = do case requestHeaderHost req of Just host -> do case…
Sojo
  • 5,455
  • 3
  • 10
  • 11
1
vote
1 answer

What does "LBS" mean in the context of WAI?

There are several identifiers in WAI containing "LBS": Network.Wai.responseLBS:: Status -> ResponseHeaders -> ByteString -> Response -- | Store uploaded files in memory lbsBackEnd:: Monad m => ignored1 -> ignored2 -> m S.ByteString -> m…
Chris Martin
  • 30,334
  • 10
  • 78
  • 137
1
vote
0 answers

How to get data from Vault

I'm use wai to build a web backend. And I want to know the which kind of data save in the requst's vault. But I don't know how to check which keys are already in this vault. I find the…
Julian.zhang
  • 709
  • 1
  • 7
  • 11
1
vote
1 answer

What to do with "release" from unwrapResumable?

I wrote a simple Wai-to-uwsgi proxy, but in doing so, I had to use unwrapResumable. That gives an unwrapped Pipe and a "release" function that needs to be called eventually. The release function's type is ResourceT IO (), and I think I want to…
tsuraan
  • 240
  • 1
  • 3
0
votes
1 answer

How to run web server (Warp) in async/concurrent mode?

I'm using https://hackage.haskell.org/package/warp-3.3.24/docs/Network-Wai-Handler-Warp.html I don't know much about haskell concurrency. Say I would like to run two servers on different ports: So I do: do Warp.run 3000 waiApp Warp.run 3002…
WHITECOLOR
  • 24,996
  • 37
  • 121
  • 181
0
votes
1 answer

Is there any way to catch all exceptions in scotty without wrapping all of my code in Exception Catching

I would like for my default handler to be able to catch all of the exceptions that my App throws but in order for this to happen I need to manually call raise after manually adding some exception catching around my IO code. below is an example…
emg184
  • 850
  • 8
  • 19