# \[ANN\] Scotty 0.22

**URL:** <https://discourse.haskell.org/t/ann-scotty-0-22/9005>\
**Category:** Announcements\
**Created:** [March 9, 2024, 10:07pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005 "2024-03-09T22:07:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)\
**Post date:** [March 9, 2024, 10:07pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005/1 "2024-03-09T22:07:11Z")

</div>

> **[scotty](https://hackage.haskell.org/package/scotty-0.22)**
>
> Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp

Another small but mighty release, with some bugfixes and some QoL improvements, as well as a number of new tests.

The [main contribution](https://github.com/scotty-web/scotty/pull/369) fixes a long-standing design issue with file handling. Now files/multipart uploads are backed by `resourcet` temporary files and guarded by `wai-extra` payload size checks, which hopefully makes it harder to DoS your server 🙂 .

Please refer to the changelog for full details. Happy hacking!

---

<div class="post-metadata">

**Author:** ![wiz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/wiz/32/2408_2.png) [@wiz](https://discourse.haskell.org/u/wiz)\
**Post date:** [March 11, 2024, 6:14pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005/2 "2024-03-11T18:14:04Z")

</div>

I wonder if it is possible/desirable to put the entire request handling into a ResourceT block, so temporary resources may be allocated while preparing the response, but freed after the response is served.

For example, using withTemporaryDir with Scotty.file reponse will raise file not found exception since the file name escapes the tmp bracket.

---

<div class="post-metadata">

**Author:** ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)\
**Post date:** [March 11, 2024, 8:27pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005/3 "2024-03-11T20:27:30Z")

</div>

You can use [`filesOpts`](https://hackage.haskell.org/package/scotty-0.22/docs/Web-Scotty-Trans.html#v:filesOpts) for that! If I understood your intent correctly. @wiz

---

<div class="post-metadata">

**Author:** ![wiz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/wiz/32/2408_2.png) [@wiz](https://discourse.haskell.org/u/wiz)\
**Post date:** [March 15, 2024, 6:06pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005/4 "2024-03-15T18:06:29Z")

</div>

Almost (=  
The bracket here is on the reading side, and in my case it was on the sending:

```haskell
handler = do
  inputs <- getUploaded
  withTemporaryDir $ \tmp ->
    dump inputs $ tmp </> "in"
    process (tmp </> "in") (tmp </> "out") -- some complicated processing that may fail
    Scotty.file $ tmp </> "out" -- "boom, file not found /tmp/xxxx/out"

```

Something can be done using builder callback, by pushing the code in there. But if something happens, then it is too late to call `Scotty.raise`.

---

<div class="post-metadata">

**Author:** ![ocramz](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.haskell.org/ocramz/32/3713_2.png) [@ocramz](https://discourse.haskell.org/u/ocramz)\
**Post date:** [March 15, 2024, 8:50pm UTC](https://discourse.haskell.org/t/ann-scotty-0-22/9005/5 "2024-03-15T20:50:49Z")

</div>

I’m not sure I got the full picture. If you have a sketch solution in mind, could you please open a ticket in the scotty repo, together with a description of your scenario ? Thanks!
