scotty-web / scotty

Haskell web framework inspired by Ruby's Sinatra, using WAI and Warp (Official Repository)
http://hackage.haskell.org/package/scotty
BSD 3-Clause "New" or "Revised" License
1.72k stars 134 forks source link

Nested WAI Applications under Scotty Routes #233

Closed sordina closed 1 year ago

sordina commented 5 years ago

This PR adds a new nested handler that allows you to place an entire WAI Application under a Scotty route.

Let me know if this implementation fits!

Simple Example:

simpleApp :: Application
simpleApp _ respond = do
    putStrLn "I've done some IO here"
    respond $ responseLBS
        status200
        [("Content-Type", "text/plain")]
        "Hello, Web!"

main :: IO ()
main = do
  scotty 3000 $ do
    get "/simple" $ nested simpleApp

Reference:

sordina commented 5 years ago

Looks like some of the apt-get CI commands are failing?

sordina commented 1 year ago

Noticed this warning when compiling:

Web/Scotty/Internal/Types.hs:168:5: warning: [-Wnoncanonical-monad-instances]
    Noncanonical ‘return’ definition detected
    in the instance declaration for ‘Monad (ActionT e m)’.
    ‘return’ will eventually be removed in favour of ‘pure’
    Either remove definition for ‘return’ (recommended) or define as ‘return = pure’
    See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return
    |
168 |     return = ActionT . return
ocramz commented 1 year ago

yes we have a ticket and a PR for this already!

On Fri, 7 Jul 2023 at 09:38, Lyndon Maydwell @.***> wrote:

Noticed this warning when compiling:

Web/Scotty/Internal/Types.hs:168:5: warning: [-Wnoncanonical-monad-instances] Noncanonical ‘return’ definition detected in the instance declaration for ‘Monad (ActionT e m)’. ‘return’ will eventually be removed in favour of ‘pure’ Either remove definition for ‘return’ (recommended) or define as ‘return = pure’ See also: https://gitlab.haskell.org/ghc/ghc/-/wikis/proposal/monad-of-no-return | 168 | return = ActionT . return

— Reply to this email directly, view it on GitHub https://github.com/scotty-web/scotty/pull/233#issuecomment-1624911874, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNBDKBAD5UMCCFWBF5M4T3XO64F7ANCNFSM4JEOOT6Q . You are receiving this because you were mentioned.Message ID: @.***>

sordina commented 1 year ago

@ocramz I've added a spec that matches the simple example from examples/nested.hs.

ocramz commented 1 year ago

wyt @fumieval is this good to merge?

ocramz commented 1 year ago

@sordina once you're able to add an entry to the Changelog I'll gladly merge. Thank you!

sordina commented 1 year ago

@ocramz Added a changelog entry under the next heading

ocramz commented 1 year ago

@sordina Thank you! all good 👍