Questions tagged [scotty]

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)

A Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp.

Scotty is the cheap and cheerful way to write RESTful, declarative web applications.

  • A page is as simple as defining the verb, url pattern, and Text content.
  • It is template-language agnostic. Anything that returns a Text value will do.
  • Conforms to WAI Application interface.
  • Uses very fast Warp webserver by default.

GitHub: https://github.com/scotty-web/scotty

104 questions
4
votes
1 answer

haskell webframeworks speed, GHCi vs Compiled

Today I did little benchmarking on my local machine to compare plain text speed of different Haskell web frameworks, and I noticed something strange. Almost all the frameworks that I tested, performed better when they were run from GHCi compared to…
milad zahedi
  • 787
  • 6
  • 21
4
votes
1 answer

Haskell-Scotty: Set custom headers (x-frame-options)

Haskell newbie here! In my haskell side project, I am using scotty to serve some dynamically generated html pages. The problem is that the pages can not be opened inside an iframe, due to the "x-frame-options" header set to "SAMEORIGIN". How can I…
afcastano
  • 548
  • 3
  • 17
4
votes
1 answer

How do I prevent scotty from eating up memory for large text output?

I have a Scotty/WAI application and one of the endpoints sends a large Text output built from a list of elements. Here is the relevant code: import Data.Text.Lazy as L import Data.Text.Lazy.Encoding as E class (Show csv) => ToCSV csv where …
insitu
  • 4,488
  • 3
  • 25
  • 42
4
votes
2 answers

Catching exceptions in Scotty / Haskell

I'm just starting out learning Haskell and am stuck on how to handle exceptions in Scotty. I have the basic function below. It gets a JSON POST, converts it in to a Haskell data record, gets a hold of a postgres connection pool from the config…
Adam
  • 304
  • 1
  • 8
4
votes
1 answer

Scotty post type wont allow effects

With: mailHandler = do name <- param "name" email <- param "email" renderSendMail $ forwardMail name email main = scotty 3000 $ post "/mail" mailHandler I get the following type error: Couldn't match type `IO' with…
Fresheyeball
  • 29,567
  • 20
  • 102
  • 164
4
votes
1 answer

Scotty Using MongoDB

I'm relatively new to Haskell, and this is my first time working with monad transformers. I'd really appreciate some help. runQuery :: Pipe -> Query -> ActionM (Either Failure [Document]) runQuery pipe query = access pipe master "nutrition" (find…
Craig
  • 255
  • 1
  • 6
3
votes
1 answer

Haskell Monads and the liftIO I don't get it

Hello community thank you for your time. I have an error and I am not sure what the error is, but what I think the problem is: There is no IO transformer from ext-1.2.4.1:Data.Text.Internal.Lazy.Text IO) to Web.Scotty.Internal.Types.ScottyT. But I…
peni4142
  • 426
  • 1
  • 7
  • 26
3
votes
1 answer

Middleware that puts data in the request vault

I'm trying to write a WAI middleware that puts some data in the request's vault, but it seems I'm missing something because I can't look it up later. Even the simplest middleware fail: fooMW :: Middleware fooMW app req sendResponse = do k <-…
Magnus
  • 4,644
  • 1
  • 33
  • 49
3
votes
0 answers

How to add a specific representation of the request and response of the body of an HTTP request with Haskell Middleware

How can i add a specific representation of the request and response body in a request logger? I would like to be able to have some typeclass that allows me to achieve this representation. In the Network.Wai.Middleware.RequestLogger.JSON I can see…
emg184
  • 850
  • 8
  • 19
3
votes
1 answer

Warp / Scotty not terminating thread / resources at end of request

I'm running into an issue where my Scotty app does not seem to terminate old HTTP request threads. And eventually, after a large number (10-20) of concurrent requests, I run into an error with too many DB connections libpq: failed (FATAL: sorry,…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
3
votes
1 answer

How should OAuth2 certs be stored in Haskell

What would the proper way to store an OAuth2 jwk in haskell? The certs i am retrieving are from https://www.googleapis.com/oauth2/v3/certs and I would like to avoid calling out for certs each time i need to verify the signature on a token. The…
emg184
  • 850
  • 8
  • 19
3
votes
1 answer

How to set a header with static middleware in Scotty?

Suppose I have a serving of static files, but they are without extension. I want to set header "Content-Type: image/png" for all of them which are serving from "some/" (1st rule). How to do it in this code? import…
RandomB
  • 3,367
  • 19
  • 30
3
votes
1 answer

Ambiguous type variable ‘a0’ arising from a use of ‘param’ prevents the constraint ‘(Parsable a0)’ from being solved

I'm having trouble understanding this error message, not too sure what I should investigate next. I've got the following imports: {-# LANGUAGE OverloadedStrings #-} module Main where import Web.Scotty import Control.Applicative import…
Chris Stryczynski
  • 30,145
  • 48
  • 175
  • 286
3
votes
1 answer

Unexpected 404 from Scotty

I'm trying to use Scotty in Haskell, and following a tutorial, I could route a url like so: get "/hello/:name" $ do name <- param "name" text ("Hello " <> name <> "!!") However, what is the syntax to capture multiple route…
Ludwik
  • 2,247
  • 2
  • 27
  • 45
3
votes
1 answer

Deploying Haskell (standalone, yesod, snap...) in Openshift fails

Whenever I try to create an application based on the Haskell cartridge, it results in the a variant of the following error: The initial build for the application failed: Shell command '/sbin/runuser -s /bin/sh 55c67c940c1e6694ac000017 -c "exec…