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
20
votes
2 answers

Scotty: connection pool as monad reader

There are trillions of monad tutorial including the reader and it seems all clear when you read about it. But when you actually need to write, it becomes a different matter. I'v never used the Reader, just never got to it in practice. So I don't…
r.sendecky
  • 9,933
  • 9
  • 34
  • 62
16
votes
3 answers

When is a generic function not generic?

I'm working on a Haskell server using scotty and persistent. Many handlers need access to the database connection pool, so I've taken to passing the pool around throughout the app, in this sort of fashion: main = do runNoLoggingT $…
Daniel Buckmaster
  • 7,108
  • 6
  • 39
  • 57
15
votes
1 answer

Unexpectedly low throughput for Network I/O using Scotty

I tried to benchmark Scotty to test the Network I/O efficiency and overall throughput. For this I set up two local servers written in Haskell. One which doesn't do anything and just acts as an API. Code for the same is {-# LANGUAGE OverloadedStrings…
user2512324
  • 791
  • 1
  • 6
  • 21
12
votes
1 answer

Use StateT within Web.Scotty

I'm trying to make a silly webserver that stores data as State. I'm using Web.Scotty. I've used ReaderT before with scotty to access config, but following the same approach doesn't work here. It resets the state on every request. I want to set the…
Sean Clark Hess
  • 15,859
  • 12
  • 52
  • 100
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
1 answer

How to fetch entity by `Int` when a `Key` is expected in the Haskell persistent library?

I use Persistent orm with scotty web framework. I want to get value from db by id. These id are coming to me from GET request There are "get" function that takes "Key Entity" variable and returns "Maybe Entity". I use following code to get value…
Daiver
  • 1,488
  • 3
  • 18
  • 47
9
votes
1 answer

Is it really a default practice to make every monad transformer an instance of MonadTrans?

So Real World Haskell says: Every monad transformer is an instance of MonadTrans but I'm playing with Scotty and found out that its base monad transformer ScottyT is not an instance of MonadTrans. Looking at the release notes it seems that it is a…
forker
  • 2,609
  • 4
  • 23
  • 24
7
votes
0 answers

User registration in Scotty

While learning Haskell I've made a small web app in Scotty framework. Next I'd like to add user registration. Registration should support email/password and Google/FaceBook login options. If user registers "on site" he should also be able to login…
Reygoch
  • 1,204
  • 1
  • 11
  • 24
7
votes
1 answer

How do I add the Reader monad to Scotty's monad?

I'm trying to use Scotty to build a very simple API. I'd like to extend the Scotty monads such that my route handler actions are able to access an unchanging environment. I believe the way to do this would be to add a Reader monad to the stack. For…
stusmith
  • 14,003
  • 7
  • 56
  • 89
6
votes
1 answer

Haskell Scotty and Elm Http NetworkError

I wanted to look into web development with haskell for the back-end and elm for the front-end. So i wrote this two simple "hello world" code code snippets elm: import Html exposing (..) import Html.Events exposing (..) import Http import Json.Decode…
6
votes
3 answers

How can I limit size of request body and headers in WAI?

I am developing an application using Scotty and of course WAI. I would like to be able to limit the size of requests, both for body length and for headers. How can I do that? Is it possible to do it using a plain WAI middleware ?
insitu
  • 4,488
  • 3
  • 25
  • 42
5
votes
1 answer

Scotty monad transformer for per-handler Reader

In the question Web, Scotty: connection pool as monad reader it is shown how to use ScottyT to embed a Reader monad in the stack to access a static configuration (in that case, a connection pool). I have a similar question, but simpler – or at least…
beta
  • 2,380
  • 21
  • 38
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
4
votes
1 answer

How to add basic auth to Scotty middleware?

I'm currently making a Scotty API and I couldn't find any examples of basicAuth implementations (Wai Middleware HttpAuth). Specifically, I want to add basic auth headers (user, pass) to SOME of my endpoints (namely, ones that start with "admin"). I…
4
votes
1 answer

Elm NetworkError on get request, but console says it's fine

I'm building my first web app in Elm, and I have this problem that when I do a get request to a local server, Elm says it is 'NetworkError' even though the browser console says that it worked. I've made a minimal example as follows: The server is…
8n8
  • 1,233
  • 1
  • 8
  • 21
1
2 3 4 5 6 7