-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple and type safe web framework that can be automatically generate API documentation. -- -- Simple and type safe web framework that can be automatically generate -- API documentation. -- --
--   {-# LANGUAGE QuasiQuotes #-}
--   {-# LANGUAGE OverloadedStrings #-}
--   
--   import Web.Apiary
--   import Network.Wai.Handler.Warp
--   import qualified Data.ByteString.Lazy.Char8 as L
--   
--   main :: IO ()
--   main = run 3000 . runApiary def $ do
--     [capture|/:Int|] . ("name" =: pLazyByteString) . stdMethod GET . action $ \age name -> do
--         guard (age >= 18)
--         contentType "text/html"
--         lbs . L.concat $ ["<h1>Hello, ", name, "!</h1>\n"]
--   
-- --
--   $ curl localhost:3000
--   404 Page Notfound.
--   $ curl 'localhost:3000/20?name=arice'
--   <h1>Hello, arice!</h1>
--   $ curl 'localhost:3000/15?name=bob'
--   404 Page Notfound.
--   $ curl -XPOST 'localhost:3000/20?name=arice'
--   404 Page Notfound.
--   
-- -- -- -- more examples: -- https://github.com/philopon/apiary/blob/master/examples/ @package apiary @version 0.12.2 module Data.Apiary.SList data SList (as :: [*]) SNil :: SList '[] (:::) :: a -> SList xs -> SList (a : xs) apply :: Fn xs r -> SList xs -> r sSnoc :: SList as -> a -> SList (Snoc as a) type Reverse (a :: [*]) = Rev a '[] sReverse :: SList as -> SList (Reverse as) instance (All Show as) => Show (SList as) -- | reexporting Network.Wai to reduce dependencies from apiary-* packages. module Web.Apiary.Wai module Data.Apiary.Param typeRep :: Typeable a => proxy a -> TypeRep jsToBool :: (IsString a, Eq a) => a -> Bool readPathAs :: Path a => proxy a -> Text -> Maybe a data Text type Param = (ByteString, ByteString) data File File :: ByteString -> ByteString -> ByteString -> ByteString -> File fileParameter :: File -> ByteString fileName :: File -> ByteString fileContentType :: File -> ByteString fileContent :: File -> ByteString data QueryRep Strict :: TypeRep -> QueryRep Nullable :: TypeRep -> QueryRep Check :: QueryRep class Typeable a => Path a where pathRep = typeRep readPath :: Path a => Text -> Maybe a pathRep :: Path a => proxy a -> TypeRep class Typeable a => Query a where queryRep = Strict . typeRep readQuery :: Query a => Maybe ByteString -> Maybe a queryRep :: Query a => proxy a -> QueryRep pBool :: Proxy Bool pInt :: Proxy Int pInt8 :: Proxy Int8 pInt16 :: Proxy Int16 pInt32 :: Proxy Int32 pInt64 :: Proxy Int64 pInteger :: Proxy Integer pWord :: Proxy Word pWord8 :: Proxy Word8 pWord16 :: Proxy Word16 pWord32 :: Proxy Word32 pWord64 :: Proxy Word64 pDouble :: Proxy Double pFloat :: Proxy Float pText :: Proxy Text pLazyText :: Proxy Text pByteString :: Proxy ByteString pLazyByteString :: Proxy ByteString pString :: Proxy String pVoid :: Proxy () pMaybe :: proxy a -> Proxy (Maybe a) pFile :: Proxy File class ReqParam a reqParams :: ReqParam a => proxy a -> Request -> [Param] -> [File] -> [(ByteString, Maybe a)] reqParamRep :: ReqParam a => proxy a -> QueryRep instance [overlap ok] Typeable Text instance [overlap ok] Typeable File instance [overlap ok] Show File instance [overlap ok] Eq File instance [overlap ok] Show QueryRep instance [overlap ok] Eq QueryRep instance [overlap ok] Query a => ReqParam a instance [overlap ok] ReqParam File instance [overlap ok] Query () instance [overlap ok] Query a => Query (Maybe a) instance [overlap ok] Query String instance [overlap ok] Query ByteString instance [overlap ok] Query ByteString instance [overlap ok] Query Text instance [overlap ok] Query Text instance [overlap ok] Query Float instance [overlap ok] Query Double instance [overlap ok] Query Word64 instance [overlap ok] Query Word32 instance [overlap ok] Query Word16 instance [overlap ok] Query Word8 instance [overlap ok] Query Word instance [overlap ok] Query Integer instance [overlap ok] Query Int64 instance [overlap ok] Query Int32 instance [overlap ok] Query Int16 instance [overlap ok] Query Int8 instance [overlap ok] Query Int instance [overlap ok] Query Bool instance [overlap ok] Path String instance [overlap ok] Path ByteString instance [overlap ok] Path ByteString instance [overlap ok] Path Text instance [overlap ok] Path Text instance [overlap ok] Path Float instance [overlap ok] Path Double instance [overlap ok] Path Word64 instance [overlap ok] Path Word32 instance [overlap ok] Path Word16 instance [overlap ok] Path Word8 instance [overlap ok] Path Word instance [overlap ok] Path Integer instance [overlap ok] Path Int64 instance [overlap ok] Path Int32 instance [overlap ok] Path Int16 instance [overlap ok] Path Int8 instance [overlap ok] Path Int instance [overlap ok] Path Bool instance [overlap ok] Path Char module Data.Apiary.Document data StrategyRep StrategyRep :: Text -> StrategyRep strategyInfo :: StrategyRep -> Text data Doc DocPath :: Text -> Doc -> Doc DocRoot :: Doc -> Doc DocFetch :: TypeRep -> (Maybe Html) -> Doc -> Doc DocMethod :: Method -> Doc -> Doc DocQuery :: ByteString -> StrategyRep -> QueryRep -> Html -> Doc -> Doc DocGroup :: Text -> Doc -> Doc Document :: (Maybe Text) -> Doc data Route Path :: Text -> Route -> Route Fetch :: TypeRep -> (Maybe Html) -> Route -> Route End :: Route data Documents Documents :: [PathDoc] -> [(Text, [PathDoc])] -> Documents noGroup :: Documents -> [PathDoc] groups :: Documents -> [(Text, [PathDoc])] data PathDoc PathDoc :: Route -> [(Method, MethodDoc)] -> PathDoc path :: PathDoc -> Route methods :: PathDoc -> [(Method, MethodDoc)] data QueryDoc QueryDoc :: ByteString -> StrategyRep -> QueryRep -> Html -> QueryDoc queryName :: QueryDoc -> ByteString queryStrategy :: QueryDoc -> StrategyRep queryRep :: QueryDoc -> QueryRep queryDocument :: QueryDoc -> Html data MethodDoc MethodDoc :: [QueryDoc] -> Text -> MethodDoc queries :: MethodDoc -> [QueryDoc] document :: MethodDoc -> Text docToDocument :: Doc -> Maybe (Maybe Text, PathDoc) mergeMethod :: [PathDoc] -> [PathDoc] docsToDocuments :: [Doc] -> Documents routeToHtml :: Route -> (Html, Html) defaultDocumentToHtml :: Documents -> Html instance Show StrategyRep instance Eq StrategyRep instance Eq Route module Control.Monad.Apiary.Filter.Internal.Strategy class Strategy (w :: * -> *) where type family SNext w (as :: [*]) a :: [*] readStrategy :: Strategy w => (v -> Maybe a) -> ((k, v) -> Bool) -> proxy (w a) -> [(k, v)] -> SList as -> Maybe (SList (SNext w as a)) strategyRep :: Strategy w => proxy w -> StrategyRep getQuery :: (v -> Maybe a) -> proxy (w a) -> ((k, v) -> Bool) -> [(k, v)] -> [Maybe a] -- | get first matched key( [1,) params to Type.). since 0.5.0.0. data Option a -- | get first matched key ( [0,) params to Maybe Type.) since 0.5.0.0. data First a -- | get key ( [1] param to Type.) since 0.5.0.0. data One a -- | get parameters ( [0,) params to [Type] ) since 0.5.0.0. data Many a -- | get parameters ( [1,) params to [Type] ) since 0.5.0.0. data Some a -- | get parameters with upper limit ( [1,n] to [Type]) since 0.6.0.0. data LimitSome u a reflectLimit :: Reifies n Int => proxy (LimitSome n a) -> Int -- | type check ( [0,) params to No argument ) since 0.5.0.0. data Check a -- | construct Option proxy. since 0.5.1.0. pOption :: proxy a -> Proxy (Option a) -- | construct First proxy. since 0.5.1.0. pFirst :: proxy a -> Proxy (First a) -- | construct One proxy. since 0.5.1.0. pOne :: proxy a -> Proxy (One a) -- | construct Many proxy. since 0.5.1.0. pMany :: proxy a -> Proxy (Many a) -- | construct Some proxy. since 0.5.1.0. pSome :: proxy a -> Proxy (Some a) -- | construct Check proxy. since 0.5.1.0. pCheck :: proxy a -> Proxy (Check a) instance Typeable1 Option instance Typeable1 First instance Typeable1 One instance Typeable1 Many instance Typeable1 Some instance Typeable2 LimitSome instance Typeable1 Check instance Strategy Check instance Reifies * u Int => Strategy (LimitSome u) instance Strategy Some instance Strategy Many instance Strategy One instance Strategy First instance Strategy Option module Control.Monad.Apiary.Action data ActionT m a data ApiaryConfig ApiaryConfig :: Application -> Status -> ResponseHeaders -> [ByteString] -> (FilePath -> ByteString) -> (Documents -> ActionT IO ()) -> ApiaryConfig -- | call when no handler matched. notFound :: ApiaryConfig -> Application -- | used unless call status function. defaultStatus :: ApiaryConfig -> Status -- | initial headers. defaultHeader :: ApiaryConfig -> ResponseHeaders -- | used by root filter. rootPattern :: ApiaryConfig -> [ByteString] mimeType :: ApiaryConfig -> FilePath -> ByteString documentationAction :: ApiaryConfig -> Documents -> ActionT IO () -- | stop handler and send current state. since 0.3.3.0. stop :: Monad m => ActionT m a -- | stop with response. since 0.4.2.0. stopWith :: Monad m => Response -> ActionT m a -- | get raw request. since 0.1.0.0. getRequest :: Monad m => ActionT m Request -- | get all request headers. since 0.6.0.0. getHeaders :: Monad m => ActionT m RequestHeaders -- | parse request body and return params. since 0.9.0.0. getReqParams :: MonadIO m => ActionT m [Param] -- | parse request body and return files. since 0.9.0.0. getReqFiles :: MonadIO m => ActionT m [File] -- | set status code. since 0.1.0.0. status :: Monad m => Status -> ActionT m () -- | add response header. since 0.1.0.0. addHeader :: Monad m => HeaderName -> ByteString -> ActionT m () -- | set response headers. since 0.1.0.0. setHeaders :: Monad m => ResponseHeaders -> ActionT m () -- | modify response header. since 0.1.0.0. modifyHeader :: Monad m => (ResponseHeaders -> ResponseHeaders) -> ActionT m () type ContentType = ByteString -- | set content-type header. if content-type header already exists, -- replace it. since 0.1.0.0. contentType :: Monad m => ContentType -> ActionT m () data File File :: ByteString -> ByteString -> ByteString -> ByteString -> File fileParameter :: File -> ByteString fileName :: File -> ByteString fileContentType :: File -> ByteString fileContent :: File -> ByteString -- | set response body file content and detect Content-Type by extension. -- since 0.1.0.0. file :: Monad m => FilePath -> Maybe FilePart -> ActionT m () -- | set response body file content, without set Content-Type. since -- 0.1.0.0. file' :: Monad m => FilePath -> Maybe FilePart -> ActionT m () -- | set response body builder. since 0.1.0.0. builder :: Monad m => Builder -> ActionT m () -- | set response body lazy bytestring. since 0.1.0.0. lbs :: Monad m => ByteString -> ActionT m () -- | set response body source. since 0.9.0.0. stream :: Monad m => StreamingBody -> ActionT m () -- | Raw response constructor. since 0.10. -- -- example(use pipes-wai) -- --
--   producer :: Monad m => Producer (Flush Builder) IO () -> ActionT m ()
--   producer = response (s h -> responseProducer s h)
--   
response :: Monad m => (Status -> ResponseHeaders -> Response) -> ActionT m () -- | Represents a streaming HTTP response body. It's a function of two -- parameters; the first parameter provides a means of sending another -- chunk of data, and the second parameter provides a means of flushing -- the data to the client. -- -- Since 3.0.0 type StreamingBody = (Builder -> IO ()) -> IO () -> IO () -- | redirect with: -- -- 303 See Other (HTTP/1.1) or 302 Moved Temporarily (Other) -- -- since 0.6.2.0. redirect :: Monad m => ByteString -> ActionT m () -- | redirect with 301 Moved Permanently. since 0.3.3.0. redirectPermanently :: Monad m => ByteString -> ActionT m () -- | redirect with: -- -- 307 Temporary Redirect (HTTP/1.1) or 302 Moved Temporarily (Other) -- -- since 0.3.3.0. redirectTemporary :: Monad m => ByteString -> ActionT m () -- | redirect handler -- -- set status and add location header. since 0.3.3.0. -- -- rename from redirect in 0.6.2.0. redirectWith :: Monad m => Status -> ByteString -> ActionT m () defaultDocumentationAction :: Monad m => ByteString -> Documents -> ActionT m () -- | redirect with 302 Found. since 0.3.3.0. -- | Deprecated: use redirect redirectFound :: Monad m => ByteString -> ActionT m () -- | redirect with 303 See Other. since 0.3.3.0. -- | Deprecated: use redirect redirectSeeOther :: Monad m => ByteString -> ActionT m () -- | Deprecated: use stream source :: Monad m => StreamingBody -> ActionT m () module Control.Monad.Apiary.Filter.Internal -- | low level filter function. function :: Monad n => (Doc -> Doc) -> (SList c -> Request -> Maybe (SList c')) -> ApiaryT c' n m b -> ApiaryT c n m b -- | filter and append argument. function' :: Monad n => (Doc -> Doc) -> (Request -> Maybe a) -> ApiaryT (Snoc as a) n m b -> ApiaryT as n m b -- | filter only(not modify arguments). function_ :: Monad n => (Doc -> Doc) -> (Request -> Bool) -> ApiaryT c n m b -> ApiaryT c n m b -- | filter by action. since 0.6.1.0. focus :: Monad n => (Doc -> Doc) -> (SList c -> ActionT n (SList c')) -> ApiaryT c' n m a -> ApiaryT c n m a module Control.Monad.Apiary.Filter -- | filter by HTTP method. since 0.1.0.0. method :: Monad n => Method -> ApiaryT c n m a -> ApiaryT c n m a -- | filter by HTTP method using StdMethod. since 0.1.0.0. stdMethod :: Monad n => StdMethod -> ApiaryT c n m a -> ApiaryT c n m a -- | http version filter. since 0.5.0.0. httpVersion :: Monad n => HttpVersion -> ApiaryT c n m b -> ApiaryT c n m b -- | http/0.9 only accepted fiter. since 0.5.0.0. http09 :: Monad n => ApiaryT c n m b -> ApiaryT c n m b -- | http/1.0 only accepted fiter. since 0.5.0.0. http10 :: Monad n => ApiaryT c n m b -> ApiaryT c n m b -- | http/1.1 only accepted fiter. since 0.5.0.0. http11 :: Monad n => ApiaryT c n m b -> ApiaryT c n m b -- | filter by rootPattern of ApiaryConfig. root :: Monad n => ApiaryT c n m b -> ApiaryT c n m b -- | capture QuasiQuoter. since 0.1.0.0. -- -- example: -- --
--   [capture|/path|] -- first path == path
--   [capture|/int/:Int|] -- first path == int && get 2nd path as Int.
--   [capture|/:Int/:Double|] -- get first path as Int and get 2nd path as Double.
--   
capture :: QuasiQuoter -- | check first path and drill down. since 0.11.0. path :: Monad n => Text -> ApiaryT c n m a -> ApiaryT c n m a -- | check consumed pathes. since 0.11.1. endPath :: Monad n => ApiaryT c n m a -> ApiaryT c n m a -- | get first path and drill down. since 0.11.0. fetch :: (Path a, Monad n) => proxy a -> Maybe Html -> ApiaryT (Snoc as a) n m b -> ApiaryT as n m b data QueryKey QueryKey :: ByteString -> Maybe Html -> QueryKey queryKey :: QueryKey -> ByteString queryDesc :: QueryKey -> Maybe Html -- | low level query getter. since 0.5.0.0. -- --
--   query key (Proxy :: Proxy (fetcher type))
--   
-- -- examples: -- --
--   query key (Proxy :: Proxy (First Int)) -- get first 'key' query parameter as Int.
--   query key (Proxy :: Proxy (Option (Maybe Int)) -- get first 'key' query parameter as Int. allow without param or value.
--   query key (Proxy :: Proxy (Many String) -- get all 'key' query parameter as String.
--   
query :: (ReqParam a, Strategy w, MonadIO n) => QueryKey -> proxy (w a) -> ApiaryT (SNext w as a) n m b -> ApiaryT as n m b -- | get first matched paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pFirst pInt) == query key (Proxy :: Proxy (First Int))
--   
(=:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT (Snoc as a) n m b -> ApiaryT as n m b -- | get one matched paramerer. since 0.5.0.0. -- -- when more one parameger given, not matched. -- --
--   key =: pInt == query key (pOne pInt) == query key (Proxy :: Proxy (One Int))
--   
(=!:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT (Snoc as a) n m b -> ApiaryT as n m b -- | get optional first paramerer. since 0.5.0.0. -- -- when illegal type parameter given, fail mather(don't give Nothing). -- --
--   key =: pInt == query key (pOption pInt) == query key (Proxy :: Proxy (Option Int))
--   
(=?:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT (Snoc as (Maybe a)) n m b -> ApiaryT as n m b -- | check parameger given and type. since 0.5.0.0. -- -- If you wan't to allow any type, give pVoid. -- --
--   key =: pInt == query key (pCheck pInt) == query key (Proxy :: Proxy (Check Int))
--   
(?:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT as n m b -> ApiaryT as n m b -- | get many paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pMany pInt) == query key (Proxy :: Proxy (Many Int))
--   
(=*:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT (Snoc as [a]) n m b -> ApiaryT as n m b -- | get some paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pSome pInt) == query key (Proxy :: Proxy (Some Int))
--   
(=+:) :: (MonadIO n, ReqParam a) => QueryKey -> proxy a -> ApiaryT (Snoc as [a]) n m b -> ApiaryT as n m b -- | query exists checker. -- --
--   hasQuery q = query q (Proxy :: Proxy (Check ()))
--   
hasQuery :: MonadIO n => QueryKey -> ApiaryT c n m a -> ApiaryT c n m a -- | check whether to exists specified header or not. since 0.6.0.0. hasHeader :: Monad n => HeaderName -> ApiaryT as n m b -> ApiaryT as n m b -- | check whether to exists specified valued header or not. since 0.6.0.0. eqHeader :: Monad n => HeaderName -> ByteString -> ApiaryT as n m b -> ApiaryT as n m b -- | filter by headers up to 100 entries. since 0.6.0.0. headers :: Monad n => HeaderName -> ApiaryT (Snoc as [ByteString]) n m b -> ApiaryT as n m b -- | filter by header and get first. since 0.6.0.0. header :: Monad n => HeaderName -> ApiaryT (Snoc as ByteString) n m b -> ApiaryT as n m b -- | low level header filter. since 0.6.0.0. header' :: (Strategy w, Monad n) => (forall x. Proxy x -> Proxy (w x)) -> (Header -> Bool) -> ApiaryT (SNext w as ByteString) n m b -> ApiaryT as n m b -- | filter by ssl accessed. since 0.1.0.0. ssl :: Monad n => ApiaryT c n m a -> ApiaryT c n m a instance IsString QueryKey module Control.Monad.Apiary -- | most generic Apiary monad. since 0.8.0.0. data ApiaryT c n m a -- | no transformer. (ActionT IO, ApiaryT Identity) type Apiary c = ApiaryT c IO Identity runApiary :: ApiaryConfig -> Apiary '[] a -> Application runApiaryT :: (Monad n, Monad m) => (forall b. n b -> IO b) -> ApiaryConfig -> ApiaryT '[] n m a -> m Application runApiaryT' :: (Monad n, Monad m) => (forall b. n b -> IO b) -> ApiaryConfig -> ApiaryT '[] n m a -> m (Application, Documents) apiaryConfig :: Monad n => ApiaryT c n m ApiaryConfig -- | splice ActionT ApiaryT. action :: Monad n => Fn c (ActionT n ()) -> ApiaryT c n m () -- | like action. but not apply arguments. since 0.8.0.0. action' :: Monad n => (SList c -> ActionT n ()) -> ApiaryT c n m () -- | API document group. since 0.12.0.0. -- -- only top level group recognized. group :: Text -> ApiaryT c n m a -> ApiaryT c n m a -- | add API document. since 0.12.0.0. -- -- It use only filters prior document, so you should be placed document -- directly in front of action. document :: Text -> ApiaryT c n m a -> ApiaryT c n m a -- | execute action before main action. since 0.4.2.0 -- | Deprecated: use action' actionWithPreAction :: Monad n => (SList xs -> ActionT n a) -> Fn xs (ActionT n ()) -> ApiaryT xs n m () module Web.Apiary -- | shortcut action. since 0.6.0.0. -- --
--   [act|200 .html|] == [act|200 text/html|] ==
--   action $ \arguments -> do
--       status 200
--       contentType text/html
--   
act :: QuasiQuoter