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
0
votes
1 answer

Testing the state updates of a wai application

I have an application written on top of Wai, configured to have some custom state and be testable with Test.Hspec.Wai. I can test request/response interactions, but I haven't been able to figure out how to test for state changes; specifically, if my…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
0
votes
1 answer

Is there a way to access cookie headers for a Wai Web App?

I have a Servant web application. I need to access the cookie headers for debugging purposes. From the browser, I can access the headers including the cookie headers. From the server, I use Wai's RequestLogger to log requests. The results do not…
7puns
  • 1,505
  • 1
  • 9
  • 9
0
votes
1 answer

WAI tutorial - no instance for (Show Response)

Again the n00b here: trying Warp and WAI with the following code as in the documentation. {-# LANGUAGE OverloadedStrings, DeriveGeneric #-} import Network.Wai import Network.HTTP.Types import Network.Wai.Handler.Warp (run) app3 :: Application app3…
Madderote
  • 1,107
  • 10
  • 19
0
votes
1 answer

How do I force warp to use a status code other than 200 when using ResponseFile?

When trying to produce a custom 404 error, I attempt to respond with responseFile notFound404 [("Content-Type","text/html")] "404.html" Nothing. However, if "404.html" is present in my filesystem, Warp sends the data with status code 200. Is this…
Tesseract
  • 526
  • 3
  • 20
0
votes
1 answer

How to read response body in WAI middleware?

I'm trying to create some middleware that will send 500 errors to a remote server. The error information is in the response body. How can I get the response body from a Response as any kind of string? I see responseToStream but I can't figure out…
Sean Clark Hess
  • 15,859
  • 12
  • 52
  • 100
0
votes
1 answer

Unable to fix "Ambiguous type variable" in Aeson and Spock

I have a Spock application where I have this: post "/test" $ do a <- jsonBody' text "test" It throws an exception: • Ambiguous type variable ‘a0’ arising from a use of ‘jsonBody'’ prevents the constraint ‘(Aeson.FromJSON…
Jodimoro
  • 4,355
  • 3
  • 11
  • 18
0
votes
1 answer

How to capture multiple URL parameters / segments?

Given a url like http://test.com/abc/xyz/1/2/3, how can I retrieve all the URL segments after abc/ so the resulting value would be ["xyz","1","2","3]?
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
0
votes
1 answer

Stream stdin to a Wai.EventSource

I would like to stream stdin over an HTTP connection using text/event-stream. The Network.Wai.EventSource thing looks like a good candidate. I tried using this code: import Network.Wai import Network.Wai.EventSource import…
RichardTowers
  • 4,682
  • 1
  • 26
  • 43
0
votes
0 answers

Adding request specific data in Yesod

I'm adding rabbitmq to my yesod application and based off the documentation(at the bottom) It looks like I'm supposed to open a new channel per thread which means a new channel per request in yesod. From what I can tell, my two options to add this…
jvans
  • 2,765
  • 2
  • 22
  • 23
0
votes
1 answer

IO monad issues when trying to implement WAI HTTP Server + Fallback Proxy

What I'm trying to do is to create a somewhat smart reverse proxy server that should process some requests on its own and forward the others to the backend of choice. To make it challenging I'm trying hard to do it in Haskell, which I am a total…
SkyWriter
  • 1,454
  • 10
  • 17
0
votes
1 answer

Type Error when Extracting Post Request

I'm trying to extract a basic post request using code from this question (except that I'm using lbsBackEnd instead of the no-longer-existing lbsSink). {-# LANGUAGE OverloadedStrings #-} import Network.Wai.Handler.Warp (run) import qualified…
Inaimathi
  • 13,853
  • 9
  • 49
  • 93
0
votes
1 answer

WAI application works ghci but not with runhaskell

I have written a simple WAI application, which uses a ReaderT to allow access to the request like so: import qualified Network.Wai as W handle :: (Resource a) => a -> ReaderT W.Request IO W.Response where handle is the function that does the bulk…
hdgarrood
  • 2,141
  • 16
  • 23
-1
votes
2 answers

Spock or Wai/Warp and HTTPS

I have a Spock web site which must be available via HTTPS. How can I setup it up properly for that? I think it should be the same way as for Wai/Warp, but still there's no information which is up to date.
1 2 3 4
5