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

`reqHeader` not in scope #261

Closed awasthishubh closed 4 years ago

awasthishubh commented 4 years ago

So I started with Haskell recently and now I am learning Scotty to make simple web server. I got this error which says reqHeader not in scope. I saw this code at different tutorials. Is something changed? Do I need to add any extra import? Code

{-# LANGUAGE OverloadedStrings #-}
import Web.Scotty
import qualified Data.Text as T
import Control.Monad.IO.Class
import Network.HTTP.Types

main = scotty 3000 $ do
    get "/" $ do
        liftIO $ putStrLn $ "XXXXXXXXXXXXXXXXXXXXXX"
        agent <- reqHeader "User-Agent"
        text agent

Error log:

Resolving dependencies...
Configuring google-oauth-0.1.0.0...
Building google-oauth-0.1.0.0...
Failed to install google-oauth-0.1.0.0
Build log ( /home/shubh/.cabal/logs/google-oauth-0.1.0.0.log ):
cabal: Entering directory '.'
Configuring google-oauth-0.1.0.0...
Building google-oauth-0.1.0.0...
Preprocessing executable 'google-oauth' for google-oauth-0.1.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, dist/build/google-oauth/google-oauth-tmp/Main.o )

src/Main.hs:10:18: error:
    • Variable not in scope:
        reqHeader
          :: [Char]
             -> Web.Scotty.Internal.Types.ActionT
                  Data.Text.Internal.Lazy.Text IO Data.Text.Internal.Lazy.Text
    • Perhaps you meant ‘setHeader’ (imported from Web.Scotty)
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
google-oauth-0.1.0.0 failed during the building phase. The exception was
chris-martin commented 4 years ago

According to the change log, reqHeader was renamed to header and deprecated in version 0.7.0, and removed in 0.8.0.