Questions tagged [haskell-warp]

A Haskell high-performance HTTP server that implements the WAI protocol

warp is a Haskell high-performance HTTP server that implements the WAI protocol.

Being developed by the same authors as Yesod, it is optimized for high performance and low overhead, being interoperable with many other frameworks.

58 questions
38
votes
1 answer

Minimal Warp webserver example

I want to create a website using the Warp webserver in Haskell. As I'm a Haskell beginner, examples like this one are too complex for me. Can anyone show me a simple, minimal example of how to use Warp? Note: This question intentionally shows no…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
12
votes
1 answer

Haskell Warp/Wai and HTTPS -- how to make them work?

I have a basic hello-world application in Haskell Servant and Warp. This is not real code but for the sake of simplicity let's say I'm using it: import Network.Wai import Network.Wai.Handler.Warp import Servant personAPI :: Proxy…
Jushiti
  • 165
  • 1
  • 10
12
votes
2 answers

Simple questions about the scotty Haskell web framework

Consider the simplest scotty app: {-# LANGUAGE OverloadedStrings #-} import Web.Scotty import Data.Monoid (mconcat) main = scotty 3000 $ do get "/:word" $ do beam <- param "word" html $ mconcat ["

Scotty, ", beam, " me…

stackoverflowuser
  • 1,157
  • 9
  • 18
10
votes
2 answers

Haskell equivalent for python -m http.server?

Is there a way to start a http server to serve static files right from shell using ghc -e or runhaskell ?
Shanthakumar
  • 757
  • 6
  • 23
9
votes
2 answers

Warp: Binding to Unix Domain Sockets

The example code listed here shows how to make warp listen only on specific hosts. Furtheremore, this post shows some basics on how to use unix domain sockets in Haskell. How can I combine those two approaches in order to make warp listen on (i.e.…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
8
votes
2 answers

Handling POST using Warp/WAI

How do you retrieve data from a POST request using Network.Wai and Warp? Say for example, I have a simple webpage ....
.... When the…
djhworld
  • 6,726
  • 4
  • 30
  • 44
6
votes
1 answer

is maxTotalHeaderLength working as expected?

Warp has a settingsMaxTotalHeaderLength field which by default is 50*1024 : https://hackage.haskell.org/package/warp-3.3.10/docs/src/Network.Wai.Handler.Warp.Settings.html#defaultSettings I suppose this means 50KB? But, when I try to send a header…
tselvan
  • 642
  • 3
  • 11
6
votes
2 answers

Listen on specific host using warp

When running a warp application using run, it listens on all IP adresses. For security reasons, I want to listen on localhost only, handling remote access using a reverse proxy. How do I need to call run to only listen on a specific host/IP? Note:…
Uli Köhler
  • 13,012
  • 16
  • 70
  • 120
5
votes
1 answer

How do I cause a WARP server to terminate?

I have an HTTP application server that needs to exit when handling a certain request under certain conditions (in order to be restarted by a supervisor). Given a main like: import Network.Wai.Handler.Warp (run) main :: IO () main = do config <-…
Jean-Paul Calderone
  • 47,755
  • 6
  • 94
  • 122
5
votes
1 answer

How to log the real IP address when behind a proxy using Scotty / wai

This is my scotty app, notice how I am logging requests to the console: {-# LANGUAGE OverloadedStrings #-} import Web.Scotty import Network.Wai.Middleware.RequestLogger import Data.Monoid (mconcat) main = scotty 3000 $ do --log requests to…
stackoverflowuser
  • 1,157
  • 9
  • 18
5
votes
2 answers

How to add a MonadThrow instance to ResourceT Monad Transformer in a Warp Server

I'm trying to build a simple reverse-proxy server using Warp (mostly for my own edification, since there are lots of other off-the-shelf options). So far, my code is mostly lifted from the Warp documentation (Writing output to file is just an…
jdo
  • 255
  • 2
  • 9
4
votes
1 answer

How to run Warp in daemonized mode?

I've been working on a pixel server built using Haskell Warp and have been struggling to work out how to run it in daemonized mode. Warp works great - I can use run from Network.Wai.Handler.Warp to serve HTTP, runTLS from Network.Wai.Handler.WarpTLS…
Alex Dean
  • 15,575
  • 13
  • 63
  • 74
4
votes
0 answers

Warp/WAI Internal Exception Handling

I am developing a Warp / WarpTLS application and a bunch of middleware (without yesod), all of which handles its own exceptions. Currently I want to deal with Exceptions raised within Warp and WarpTLS and I am unclear about what exceptions can occur…
elfeck
  • 385
  • 1
  • 8
4
votes
2 answers

Thread-safe state with Warp/WAI

I want to write a web server which stores its state in a State monad with wai/warp. Something like this: {-# LANGUAGE OverloadedStrings #-} import Network.Wai import Network.Wai.Handler.Warp import Network.HTTP.Types import…
nponeccop
  • 13,527
  • 1
  • 44
  • 106
3
votes
1 answer

Is it safe to run two warp servers from the same `main`?

There seem to be some "global vars" (unsafePerformIO + NOINLINE) in warps code base. Is it safe to run two instances of warp from the same main function, despite this?
Georgi Lyubenov
  • 366
  • 1
  • 5
1
2 3 4