-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Web Application Abstraction -- -- Web Astraction Layer with a binding to CGI providing a simple way to -- map parameter and header values to data structures (inspired by HAppS) -- and a sitemap functionality to map URLs to functions that answer the -- request. @package haskoon @version 0.1 module Factis.Haskoon.Web class (Monad m) => Web m where { type family WebRes m; { webGetParam n = liftM (lookup n) webGetParams webGetHeader n = liftM lookup webGetHeaders where lookup = fmap snd . find ((== map toLower n) . map toLower . fst) webSendError status msg = do { webSetStatus status Nothing; webSetHeader "Content-Type" "text/plain; charset=UTF-8"; webSendBSL (fromString msg) } } } webDocumentRoot :: (Web m) => m FilePath webContainerUri :: (Web m) => m URI webRequestUri :: (Web m) => m URI webPathInfo :: (Web m) => m String webMethod :: (Web m) => m String webGetBody :: (Web m) => m ByteString webGetParams :: (Web m) => m [(String, String)] webGetHeaders :: (Web m) => m [(String, String)] webGetCookies :: (Web m) => m [(String, String)] webSetStatus :: (Web m) => Int -> Maybe String -> m () webSendBSL :: (Web m) => ByteString -> m (WebRes m) webSetHeader :: (Web m) => String -> String -> m () webFail :: (Web m) => String -> m a webSetCookie :: (Web m) => Cookie -> m () webUnsetCookie :: (Web m) => Cookie -> m () webGetRepls :: (Web m) => m [String] webWithRepls :: (Web m) => [String] -> m a -> m a webRunFromRq :: (Web m, FromRq a) => m (Either String a) webLog :: (Web m) => String -> Priority -> String -> m () webSendError :: (Web m) => Int -> String -> m (WebRes m) webGetHeader :: (Web m) => String -> m (Maybe String) webGetParam :: (Web m) => String -> m (Maybe String) class (MonadIO m, Web m) => WebIO m class (MonadPlus m) => RqAccess m param :: (RqAccess m) => String -> m String header :: (RqAccess m) => String -> m String repl :: (RqAccess m) => Int -> m String cookie :: (RqAccess m) => String -> m String checkMethod :: (RqAccess m) => (String -> Bool) -> m String class FromRq a fromRq :: (FromRq a, RqAccess m) => m a class ToWebRes a toWebContentType :: (ToWebRes a) => a -> String toWebBody :: (ToWebRes a) => a -> ByteString toWebRes :: (ToWebRes a, Web m) => a -> m (WebRes m) type WebWebRes m = m (WebRes m) webRepl :: (Web m) => Int -> m String webOk :: (Web m, ToWebRes a) => a -> m (WebRes m) webNotFound :: (Web m) => [Char] -> m (WebRes m) webFileNotFound :: (Web m) => [Char] -> m (WebRes m) webBadRequest :: (Web m) => [Char] -> m (WebRes m) webSendString :: (Web m) => String -> m (WebRes m) webGetCookie :: (Web m) => String -> m (Maybe String) webRedirect :: (Web m) => Bool -> String -> m (WebRes m) webWithData :: (Web m, FromRq a) => (a -> m (WebRes m)) -> m (WebRes m) webCheckData :: (Web m, FromRq a) => (a -> m (WebRes m)) -> (String -> m (WebRes m)) -> m (WebRes m) webSendFile :: (WebIO m) => FilePath -> m (WebRes m) notEmpty :: (Monad m) => m String -> m String optional :: (MonadPlus m) => m a -> m (Maybe a) webLogNotice :: (Web m) => String -> m () webLogTrace :: (Web m) => String -> m () webLogDebug :: (Web m) => String -> m () -- | Contains all information about a cookie set by the server. data Cookie :: * Cookie :: String -> String -> Maybe CalendarTime -> Maybe String -> Maybe String -> Bool -> Cookie -- | Name of the cookie. cookieName :: Cookie -> String -- | Value of the cookie. cookieValue :: Cookie -> String -- | Expiry date of the cookie. If Nothing, the cookie expires when -- the browser sessions ends. If the date is in the past, the client -- should delete the cookie immediately. cookieExpires :: Cookie -> Maybe CalendarTime -- | The domain suffix to which this cookie will be sent. cookieDomain :: Cookie -> Maybe String -- | The path to which this cookie will be sent. cookiePath :: Cookie -> Maybe String -- | True if this cookie should only be sent using secure means. cookieSecure :: Cookie -> Bool -- | Construct a cookie with only name and value set. This client will -- expire when the browser sessions ends, will only be sent to the server -- and path which set it and may be sent using any means. newCookie :: String -> String -> Cookie -- | Get the value of a cookie from a string on the form -- "cookieName1=cookieValue1;...;cookieName2=cookieValue2". This -- is the format of the Cookie HTTP header. findCookie :: String -> String -> Maybe String -- | Delete a cookie from the client by setting the cookie expiry date to a -- date in the past. deleteCookie :: Cookie -> Cookie -- | Show a cookie on the format used as the value of the Set-Cookie -- header. showCookie :: Cookie -> String -- | Gets all the cookies from a Cookie: header value readCookies :: String -> [(String, String)] instance ToWebRes String module Factis.Haskoon.WebSitemap data SitemapT m a type Sitemap m = [SitemapT m (WebRes m)] liftMaybe :: (Web m) => m (Maybe a) -> SitemapT m a matchFirst :: (Web m) => [SitemapT m (WebRes m)] -> SitemapT m (WebRes m) matchPath :: (Web m) => String -> SitemapT m (WebRes m) -> SitemapT m (WebRes m) matchRegex :: (Web m) => String -> SitemapT m (WebRes m) -> SitemapT m (WebRes m) matchMeth :: (Web m) => String -> SitemapT m a -> SitemapT m a runSitemapT :: (Web m) => SitemapT m a -> m (Maybe a) fromSitemapT :: (Web m) => SitemapT m (WebRes m) -> m (WebRes m) -> m (WebRes m) runSitemap :: (Web m) => Sitemap m -> m (WebRes m) runWithSitemap :: (Web m) => (m (WebRes m) -> a) -> Sitemap m -> a instance (Monad m) => Monad (SitemapT m) instance (MonadIO m) => MonadIO (SitemapT m) instance MonadTrans SitemapT instance (MonadIO m, Web m) => WebIO (SitemapT m) instance (Web m) => MonadPlus (SitemapT m) instance (Web m) => Web (SitemapT m) module Factis.Haskoon.WebRqAccessM data RqData RqData :: String -> [(String, String)] -> [(String, String)] -> [String] -> [(String, String)] -> RqData rqd_method :: RqData -> String rqd_params :: RqData -> [(String, String)] rqd_headers :: RqData -> [(String, String)] rqd_repls :: RqData -> [String] rqd_cookies :: RqData -> [(String, String)] class (MonadPlus m) => RqAccess m param :: (RqAccess m) => String -> m String header :: (RqAccess m) => String -> m String repl :: (RqAccess m) => Int -> m String cookie :: (RqAccess m) => String -> m String checkMethod :: (RqAccess m) => (String -> Bool) -> m String newtype RqAccessM a RqAccessM :: (RqRead a) -> RqAccessM a runRqAccessM :: RqAccessM t -> RqData -> Either String t instance Monad RqAccessM instance MonadPlus RqAccessM instance RqAccess RqAccessM module Factis.Haskoon.WebCGI data WebCGI m a runFastCgi :: String -> CGIT IO CGIResult -> IO () runFastWebCGI :: String -> WebWebRes (WebCGI (CGIT IO)) -> IO () runWebCGI :: (MonadCGI m, MonadIO m) => WebCGI m a -> m (Either String a) runWebCGIResult :: (MonadIO m, MonadCGI m) => WebCGI m (WebRes (WebCGI m)) -> m CGIResult instance (Monad m) => Monad (WebCGI m) instance (MonadIO m) => MonadIO (WebCGI m) instance (MonadCGI m, MonadIO m) => WebIO (WebCGI m) instance (MonadCGI m) => MonadCGI (MaybeT m) instance (MonadIO m, MonadCGI m) => Web (WebCGI m) module Factis.Haskoon.WebHsp type HSPT m :: (* -> *) = XMLGenT (HSPT' m) -- | The XML datatype representation. Is either an Element or CDATA. data XML :: * asChild :: (EmbedAsChild m c) => c -> GenChildList m genElement :: (XMLGen m) => Name -> [XMLGenT m [Attribute m]] -> [XMLGenT m [Child m]] -> XMLGenT m (XML m) genEElement :: (XMLGen m) => Name -> [XMLGenT m [Attribute m]] -> XMLGenT m (XML m) asAttr :: (EmbedAsAttr m a) => a -> GenAttributeList m data Attr n a :: * -> * -> * (:=) :: n -> a -> Attr n a webHspHtml :: (WebIO m) => HSPT m XML -> m (WebRes m) webToHsp :: (Web m) => m a -> HSPT m a