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

Migration from servant-0.4.4.7 to servant-0.7.1

I used the servant-0.4.4.7. Below is my model code: type API = ServletAPI :<|> Raw type AppM = ReaderT Config (EitherT ServantErr IO) runApplication :: IO () runApplication = do configApp <- initializationConfig case configApp of …
QSpider
  • 537
  • 2
  • 10
2
votes
1 answer

Wai Request Copying

I would like to be able to use the content of the body of a request to be used as part of a cache key. My current code looks like: caching app req respond = -- Request Body is consumed here cacheKey <- strictRequestBody req -- the req…
yogsototh
  • 14,371
  • 1
  • 22
  • 21
2
votes
1 answer

Why does this work in GHCi but not Scotty?

I am trying to make a webpage that will list the contents of a given directory, but I am running into a strange problem: The code produces the desired output when I run it line by line in GHCi, but when it is executed in the running Scotty instance,…
asg0451
  • 493
  • 4
  • 13
2
votes
0 answers

Haskell websocket closes after inactivity?

I have a snippet which looks like this after connection is opened receiveEvents :: WS.Connection -> Document -> IO() receiveEvents conn document = forever $ do putStrLn "receive events" evnt <- WS.receiveData conn let val =…
moiz virani
  • 204
  • 2
  • 5
2
votes
1 answer

How can I go from a Wai Request to a Yesod Route?

I'd like to use the Wai HttpAuth Middleware to hide a few pages behind HTTP basic auth. For this the HttpAuth middleware provides authIsProtected :: !(Request -> IO Bool). To implement authIsProtected I need to check if the URL is admin-only; it…
MaxGabriel
  • 7,617
  • 4
  • 35
  • 82
2
votes
1 answer

Is there anything like sprockets for haskell?

The Ruby library, Sprockets, allows you to set up an environment consisting of one or more load paths, and then can serve static files under those paths over HTTP. It also will do ETags and preprocessing (for example, if you want to use CoffeeScript…
hdgarrood
  • 2,141
  • 16
  • 23
2
votes
2 answers

redirect to index using staticApp with defaultWebAppSettings

I'm using the wai-app-static static package to serve a small website. Originally I called it as: staticApp defaultFileServerSettings root and all was right with the world. I wanted to switch to using defaultWebAppSettings, though, (as this is a…
2
votes
2 answers

Trouble running Warp, on WAI, in Windows

I've written a simple Hello World application for (Warp) on (Wai). It works fine in Ubuntu Linux, as do more complicated apps. But I can't even get this Hello World app to run in Windows. I'm using Haskell Platform (installation file 2012.2.0.0) on…
jerng
  • 499
  • 6
  • 13
2
votes
1 answer

Where to add 'always running' thread to Yesod applications

I'm writing a Yesod application, but it also needs to fork several non-web services. (UDP listeners, TCP listening port, etc.) Where is the correct place to splice in a fork, such that this work seamlessly, regardless of whether my app is running…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
1
vote
1 answer

Warp web service with a long lived resource (a file handle)

I'm trying to understand how to write a web service using warp that has a long lived resource that I want access to from all my requests (i.e. I want the resource to exist for the life time of server, not per request). I'm assuming this is a use for…
thatismatt
  • 9,832
  • 10
  • 42
  • 54
1
vote
4 answers

How to consume a conduit with WAI (raw request body)

I'm using scotty, which is a sinatra-like wrapper around WAI. I want to get the raw request body as a byte string so I can parse it as json. The following is close. This is similar to other questions about consuming a body using WAI, but is…
Sean Clark Hess
  • 15,859
  • 12
  • 52
  • 100
1
vote
1 answer

Haskell wai middleware - how to run application if 404 is returned from the first application?

I'm trying to 'join' two wai Applications together. Essentially the first app will either serve a 404 Not found response or a response that is not a 404 Not found response. I'd like to add a second application that will attempt to process the…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
1
vote
1 answer

wai-logger FileLogSpec as Scotty Middleware reporting openFile: resource busy (file is locked)

I am using Scotty for a backend application in Haskell and I am interested in logging all requests to a file. The existing wai-middleware requestlogger is not enough as I would like the properties of FileLogSpec, since I like have multiple but short…
Casper Thule Hansen
  • 1,510
  • 2
  • 19
  • 36
1
vote
1 answer

Improper route construction with Servant and Raw WAI directoryServer

As part of a Haskell Servant project, I'm trying to provide a directory server as an endpoint, i.e. type DirServe = Capture "route" Text :> Raw When I navigate to my page, e.g. localhost:8081/myRoute Which is serving myDir/ fileA fileB I…
trevor cook
  • 1,531
  • 8
  • 22
1
vote
1 answer

Get absolute-form request target of HTTP request using WAI

The Request type provides accessors for the request method and the request version but not for the bit in between. So if I have the following request: GET http://www.example.org/index.html HTTP/1.1 I want the http://www.example.org/index.html in…
Philippe
  • 1,715
  • 4
  • 25
  • 49