{-# LANGUAGE OverloadedStrings #-}
module Websave.Web.Data
  ( getData
  ) where

import Control.Monad (join)
import Data.ByteString (ByteString)
import Network.Wai (queryString)
import Yesod.Core (MonadHandler, getRequest, reqWaiRequest)

-- TODO move to YesodTools
-- TODO process POST data as well
getData :: MonadHandler m => m (Maybe ByteString)
getData = join . lookup "data" . queryString . reqWaiRequest <$> getRequest
