I wanted to create an api server using wai and warp in Haskell.
I want to change the request to ByteString and pass it to the function, but it doesn't work.
Thank you for your cooperation
app::Application
app request response = response $case rawPathInfo request of
"/" ->htmlIndex
"/raw" - > plainIndex
_->function$rawPathInfo request
function::ByteString->Response
function req = responseLBS
status200
[("Content-Type", "text/plain")]
req
This is probably a type mismatch between the regular ByteString and the delay ByteString.
If you include each module name, you will see the following:
These are different types.To do this, you can convert the return value of the function rawPathInfo in the function Data.ByteString.Lazy.fromStrict.
For example, a definition file that can be read into the interactive environment:
{-#LANGUAGE OverloadedStrings#-}
import Network.Wai
import Network.Wai.Handler.Warp
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as LBS
app::Application
app request response = response $case rawPathInfo request of
rp->function rp
function::BS.ByteString->Response
function req = responseLBS
undefined
[("Content-Type", "text/plain")]
(LBS.fromStrictreq)
© 2024 OneMinuteCode. All rights reserved.