-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Simple web framework inspired by scotty. -- -- Simple web framework inspired by scotty. -- --
--   {-# 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.7.0.0 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) 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)) 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 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 Data.Apiary.Param jsToBool :: (IsString a, Eq a) => a -> Bool class Path a readPath :: Path a => Text -> Maybe a class Query a readQuery :: Query a => Maybe ByteString -> Maybe a 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) instance Query () instance Query a => Query (Maybe a) instance Query String instance Query ByteString instance Query ByteString instance Query Text instance Query Text instance Query Float instance Query Double instance Query Word64 instance Query Word32 instance Query Word16 instance Query Word8 instance Query Word instance Query Integer instance Query Int64 instance Query Int32 instance Query Int16 instance Query Int8 instance Query Int instance Query Bool instance Path String instance Path ByteString instance Path ByteString instance Path Text instance Path Text instance Path Float instance Path Double instance Path Word64 instance Path Word32 instance Path Word16 instance Path Word8 instance Path Word instance Path Integer instance Path Int64 instance Path Int32 instance Path Int16 instance Path Int8 instance Path Int instance Path Bool instance Path Char module Control.Monad.Apiary.Action data Action a data ApiaryConfig ApiaryConfig :: Application -> Status -> ResponseHeaders -> [ByteString] -> (FilePath -> ByteString) -> 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 -- | stop handler and send current state. since 0.3.3.0. stop :: Action a -- | stop with response. since 0.4.2.0. stopWith :: Response -> Action a -- | get raw request. since 0.1.0.0. getRequest :: Action Request -- | get all request headers. since 0.6.0.0. getHeaders :: Action RequestHeaders -- | set status code. since 0.1.0.0. status :: Status -> Action () -- | add response header. since 0.1.0.0. addHeader :: HeaderName -> ByteString -> Action () -- | set response headers. since 0.1.0.0. setHeaders :: ResponseHeaders -> Action () -- | modify response header. since 0.1.0.0. modifyHeader :: (ResponseHeaders -> ResponseHeaders) -> Action () -- | set content-type header. if content-type header already exists, -- replace it. since 0.1.0.0. contentType :: ByteString -> Action () -- | set response body file content and detect Content-Type by extension. -- since 0.1.0.0. file :: FilePath -> Maybe FilePart -> Action () -- | set response body file content, without set Content-Type. since -- 0.1.0.0. file' :: FilePath -> Maybe FilePart -> Action () -- | set response body builder. since 0.1.0.0. builder :: Builder -> Action () -- | set response body lazy bytestring. since 0.1.0.0. lbs :: ByteString -> Action () -- | set response body source. since 0.1.0.0. source :: Source IO (Flush Builder) -> Action () -- | redirect with: -- -- 303 See Other (HTTP/1.1) or 302 Moved Temporarily (Other) -- -- since 0.6.2.0. redirect :: ByteString -> Action () -- | redirect with 301 Moved Permanently. since 0.3.3.0. redirectPermanently :: ByteString -> Action () -- | redirect with: -- -- 307 Temporary Redirect (HTTP/1.1) or 302 Moved Temporarily (Other) -- -- since 0.3.3.0. redirectTemporary :: ByteString -> Action () -- | redirect handler -- -- set status, add location header. since 0.3.3.0. -- -- rename from redirect in 0.6.2.0. redirectWith :: Status -> ByteString -> Action () -- | redirect with 302 Found. since 0.3.3.0. -- | Deprecated: use redirect redirectFound :: ByteString -> Action () -- | redirect with 303 See Other. since 0.3.3.0. -- | Deprecated: use redirect redirectSeeOther :: ByteString -> Action () module Control.Monad.Apiary.Filter.Internal -- | low level filter function. function :: (SList c -> Request -> Maybe (SList c')) -> Apiary c' b -> Apiary c b -- | filter and append argument. function' :: (Request -> Maybe a) -> Apiary (Snoc as a) b -> Apiary as b -- | filter only(not modify arguments). function_ :: (Request -> Bool) -> Apiary c b -> Apiary c b -- | filter by action. since 0.6.1.0. focus :: (SList c -> Action (SList c')) -> Apiary c' a -> Apiary c a module Control.Monad.Apiary data Apiary c a runApiary :: ApiaryConfig -> Apiary '[] a -> Application apiaryConfig :: Apiary c ApiaryConfig action :: Fn c (Action ()) -> Apiary c () -- | execute action before main action. since v0.4.2.0 actionWithPreAction :: (SList xs -> Action a) -> Fn xs (Action ()) -> Apiary xs () module Control.Monad.Apiary.Filter.Internal.Capture data Equal Equal :: Text -> Equal type Fetch = Proxy class CaptureElem a where type family Next a (xs :: [*]) :: [*] captureElem :: CaptureElem a => a -> Text -> SList xs -> Maybe (SList (Next a xs)) type Capture as = All CaptureElem as capture' :: Capture as => SList as -> [Text] -> SList xs -> Maybe (SList (CaptureResult xs as)) -- | low level (without Template Haskell) capture. since 0.4.2.0 -- --
--    myCapture :: SList '[Equal, Fetch Int, Fetch String]
--    myCapture = Equal "path" ::: pInt ::: pString ::: SNil
--   
--   capture myCapture . stdMethod GET . action $ age name -> do
--        yourAction
--   
capture :: Capture as => SList as -> Apiary (CaptureResult xs as) b -> Apiary xs b instance Path a => CaptureElem (Fetch a) instance CaptureElem Equal module Control.Monad.Apiary.Filter -- | filter by HTTP method. since 0.1.0.0. method :: Method -> Apiary c a -> Apiary c a -- | filter by HTTP method using StdMethod. since 0.1.0.0. stdMethod :: StdMethod -> Apiary c a -> Apiary c a -- | http version filter. since 0.5.0.0. httpVersion :: HttpVersion -> Apiary c b -> Apiary c b -- | http/0.9 only accepted fiter. since 0.5.0.0. http09 :: Apiary c b -> Apiary c b -- | http/1.0 only accepted fiter. since 0.5.0.0. http10 :: Apiary c b -> Apiary c b -- | http/1.1 only accepted fiter. since 0.5.0.0. http11 :: Apiary c b -> Apiary c b -- | filter by rootPattern of ApiaryConfig. root :: Apiary c b -> Apiary c 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 -- | 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 :: (Query a, Strategy w) => ByteString -> Proxy (w a) -> Apiary (SNext w as a) b -> Apiary as b -- | get first matched paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pFirst pInt) == query key (Proxy :: Proxy (First Int))
--   
(=:) :: Query a => ByteString -> Proxy a -> Apiary (Snoc as a) b -> Apiary as 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))
--   
(=!:) :: Query a => ByteString -> Proxy a -> Apiary (Snoc as a) b -> Apiary as 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))
--   
(=?:) :: Query a => ByteString -> Proxy a -> Apiary (Snoc as (Maybe a)) b -> Apiary as 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))
--   
(?:) :: Query a => ByteString -> Proxy a -> Apiary as b -> Apiary as b -- | get many paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pMany pInt) == query key (Proxy :: Proxy (Many Int))
--   
(=*:) :: Query a => ByteString -> Proxy a -> Apiary (Snoc as [a]) b -> Apiary as b -- | get some paramerer. since 0.5.0.0. -- --
--   key =: pInt == query key (pSome pInt) == query key (Proxy :: Proxy (Some Int))
--   
(=+:) :: Query a => ByteString -> Proxy a -> Apiary (Snoc as [a]) b -> Apiary as b -- | query exists checker. -- --
--   hasQuery q = query q (Proxy :: Proxy (Check ()))
--   
hasQuery :: ByteString -> Apiary c a -> Apiary c a -- | check whether to exists specified header or not. since 0.6.0.0. hasHeader :: HeaderName -> Apiary as b -> Apiary as b -- | check whether to exists specified valued header or not. since 0.6.0.0. eqHeader :: HeaderName -> ByteString -> Apiary as b -> Apiary as b -- | filter by headers up to 100 entries. since 0.6.0.0. headers :: HeaderName -> Apiary (Snoc as [ByteString]) b -> Apiary as b -- | filter by header and get first. since 0.6.0.0. header :: HeaderName -> Apiary (Snoc as ByteString) b -> Apiary as b -- | low level header filter. since 0.6.0.0. header' :: Strategy w => (forall x. Proxy x -> Proxy (w x)) -> (Header -> Bool) -> Apiary (SNext w as ByteString) b -> Apiary as b -- | filter by ssl accessed. since 0.1.0.0. ssl :: Apiary c a -> Apiary c a 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