-- 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. -- @package apiary @version 0.17.2 module Data.Apiary.Proxy module Data.Apiary.SList data SList (as :: [*]) SNil :: SList [] (:::) :: a -> SList xs -> SList (a : xs) type Fn c a = Apply (Reverse c) a apply :: Fn c r -> SList c -> r apply' :: Apply xs r -> SList xs -> r type Reverse (a :: [*]) = Rev a [] sReverse :: SList as -> SList (Reverse as) instance [overlap ok] (All Show as) => Show (SList as) -- | reexporting Network.Wai to reduce dependencies from apiary-* packages. module Web.Apiary.Wai module Data.Apiary.Extension.Internal data Extensions (es :: [*]) NoExtension :: Extensions [] AddExtension :: (e :: *) -> Extensions es -> Extensions (e : es) class Has a (as :: [*]) getExtension :: Has a as => proxy a -> Extensions as -> a newtype Initializer m i o Initializer :: (forall a. Extensions i -> (Extensions o -> m a) -> m a) -> Initializer m i o unInitializer :: Initializer m i o -> forall a. Extensions i -> (Extensions o -> m a) -> m a instance [overlap ok] Monad m => Category (Initializer m) instance [overlap ok] Has a as => Has a (a' : as) instance [overlap ok] Has a (a : as) module Data.Apiary.Extension class Has a (as :: [*]) getExtension :: Has a as => proxy a -> Extensions as -> a data Extensions (es :: [*]) addExtension :: e -> Extensions es -> Extensions (e : es) noExtension :: Monad m => Initializer m i i data Initializer m i o initializer :: Monad m => (Extensions es -> m e) -> Initializer m es (e : es) type Initializer' m a = forall i. Initializer m i (a : i) initializer' :: Monad m => m e -> Initializer' m e initializerBracket :: (forall a. Extensions es -> (e -> m a) -> m a) -> Initializer m es (e : es) initializerBracket' :: (forall a. (e -> m a) -> m a) -> Initializer m es (e : es) -- | combine two Initializer. since 0.16.0. (+>) :: Monad m => Initializer m i x -> Initializer m x o -> Initializer m i o -- | Deprecated: DEPRECATED preAction :: Monad m => m a -> Initializer m i i module Data.Apiary.Method data Method GET :: Method POST :: Method HEAD :: Method PUT :: Method DELETE :: Method TRACE :: Method CONNECT :: Method OPTIONS :: Method PATCH :: Method NonStandard :: ByteString -> Method renderMethod :: Method -> ByteString dispatchMethod :: a -> a -> a -> a -> a -> a -> a -> a -> a -> (ByteString -> a) -> ByteString -> a parseMethod :: ByteString -> Method instance Eq Method instance Ord Method instance Read Method instance Show Method instance IsString Method instance Hashable Method module Data.Apiary.Param 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 NoValue :: QueryRep class Path a readPath :: Path a => Text -> Maybe a pathRep :: Path a => proxy a -> TypeRep readText :: Reader a -> Text -> (Maybe a) readTextInt :: Integral i => Text -> Maybe i readTextWord :: Integral i => Text -> Maybe i readTextDouble :: Text -> Maybe Double -- | javascript boolean. when "false", "0", "-0", "", "null", "undefined", -- "NaN" then False, else True. since 0.6.0.0. class Query a where queryRep = Strict . qTypeRep readQuery :: Query a => Maybe ByteString -> Maybe a queryRep :: Query a => proxy a -> QueryRep qTypeRep :: Query a => proxy a -> TypeRep readBS :: (ByteString -> Maybe (a, ByteString)) -> ByteString -> Maybe a readBSInt :: Integral a => ByteString -> Maybe a readBSWord :: Integral a => ByteString -> Maybe a readBSDouble :: ByteString -> Maybe Double -- | javascript boolean. when "false", "0", "-0", "", "null", "undefined", -- "NaN" then False, else True. since 0.6.0.0. -- | fuzzy date parse. three decimal split by 1 char. if year < 100 then -- + 2000. since 0.16.0. -- -- example: -- --
-- producer :: Monad m => Producer (Flush Builder) IO () -> ActionT exts m () -- producer = response (s h -> responseProducer s h) --rawResponse :: Monad m => (Status -> ResponseHeaders -> Response) -> ActionT exts 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 exts m () -- | redirect with 301 Moved Permanently. since 0.3.3.0. redirectPermanently :: Monad m => ByteString -> ActionT exts m () -- | redirect with: -- -- 307 Temporary Redirect (HTTP/1.1) or 302 Moved Temporarily (Other) -- -- since 0.3.3.0. redirectTemporary :: Monad m => ByteString -> ActionT exts 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 exts m () -- | redirect with 302 Found. since 0.3.3.0. -- | Deprecated: use redirect redirectFound :: Monad m => ByteString -> ActionT exts m () -- | redirect with 303 See Other. since 0.3.3.0. -- | Deprecated: use redirect redirectSeeOther :: Monad m => ByteString -> ActionT exts m () -- | Deprecated: use stream source :: Monad m => StreamingBody -> ActionT exts m () -- | append response body from lazy bytestring. since 0.1.0.0. -- | Deprecated: use lazyBytes lbs :: Monad m => ByteString -> ActionT exts m () module Control.Monad.Apiary.Filter.Internal -- | low level filter function. function :: Monad actM => (Doc -> Doc) -> (SList prms -> Request -> Maybe (SList prms')) -> ApiaryT exts prms' actM m () -> ApiaryT exts prms actM m () -- | filter and append argument. function' :: Monad actM => (Doc -> Doc) -> (Request -> Maybe prm) -> ApiaryT exts (prm : prms) actM m () -> ApiaryT exts prms actM m () -- | filter only(not modify arguments). function_ :: Monad actM => (Doc -> Doc) -> (Request -> Bool) -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | filter by action. since 0.6.1.0. focus :: Monad actM => (Doc -> Doc) -> (SList prms -> ActionT exts actM (SList prms')) -> ApiaryT exts prms' actM m () -> ApiaryT exts prms actM m () module Control.Monad.Apiary.Filter -- | filter by HTTP method. since 0.1.0.0. -- --
-- method GET -- stdmethod -- method "HOGE" -- non standard method --method :: Monad actM => Method -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | http version filter. since 0.5.0.0. httpVersion :: Monad actM => HttpVersion -> Html -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | http/0.9 only accepted fiter. since 0.5.0.0. http09 :: Monad actM => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | http/1.0 only accepted fiter. since 0.5.0.0. http10 :: Monad actM => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | http/1.1 only accepted fiter. since 0.5.0.0. http11 :: Monad actM => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | filter by rootPattern of ApiaryConfig. root :: (Monad m, Monad actM) => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | 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|/**|] -- feed greedy and get all path as [Text] (since 0.17.0). --capture :: QuasiQuoter -- | check first path and drill down. since 0.11.0. path :: Monad actM => Text -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | check consumed paths. since 0.11.1. endPath :: Monad actM => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | get first path and drill down. since 0.11.0. fetch :: (Path p, Monad actM) => proxy p -> Maybe Html -> ApiaryT exts (p : prms) actM m () -> ApiaryT exts prms actM m () data QueryKey QueryKey :: ByteString -> Maybe Html -> QueryKey queryKey :: QueryKey -> ByteString queryDesc :: QueryKey -> Maybe Html (??) :: QueryKey -> Html -> QueryKey -- | low level query getter. since 0.5.0.0. -- --
-- query "key" (Proxy :: Proxy (fetcher type)) ---- -- examples: -- --
-- query "key" (First :: First Int) -- get first 'key' query parameter as Int. -- query "key" (Option :: Option (Maybe Int)) -- get first 'key' query parameter as Int. allow without param or value. -- query "key" (Many :: Many String) -- get all 'key' query parameter as String. --query :: (ReqParam a, Strategy w, MonadIO actM) => QueryKey -> w a -> ApiaryT exts (SNext w prms a) actM m () -> ApiaryT exts prms actM m () -- | get first matched paramerer. since 0.5.0.0. -- --
-- "key" =: pInt == query "key" (pFirst pInt) == query "key" (First :: First Int) --(=:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts (p : prms) actM m () -> ApiaryT exts prms actM m () -- | get one matched paramerer. since 0.5.0.0. -- -- when more one parameger given, not matched. -- --
-- "key" =: pInt == query "key" (pOne pInt) == query "key" (One :: One Int) --(=!:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts (p : prms) actM m () -> ApiaryT exts prms actM m () -- | get optional first paramerer. since 0.5.0.0. -- -- when illegal type parameter given, fail match(don't give Nothing). -- --
-- "key" =: pInt == query "key" (pOption pInt) == query "key" (Option :: Option Int) --(=?:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts (Maybe p : prms) actM m () -> ApiaryT exts prms actM m () -- | get optional first paramerer with default. since 0.16.0. -- -- when illegal type parameter given, fail match(don't give Nothing). -- --
-- "key" =: (0 :: Int) == query "key" (pOptional (0 :: Int)) == query "key" (Optional 0 :: Optional Int) --(=?!:) :: (MonadIO actM, ReqParam p, Show p) => QueryKey -> p -> ApiaryT exts (p : prms) actM m () -> ApiaryT exts prms actM m () -- | 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" (Check :: Check Int) --(?:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | get many paramerer. since 0.5.0.0. -- --
-- "key" =: pInt == query "key" (pMany pInt) == query "key" (Many :: Many Int) --(=*:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts ([p] : prms) actM m () -> ApiaryT exts prms actM m () -- | get some paramerer. since 0.5.0.0. -- --
-- "key" =: pInt == query "key" (pSome pInt) == query "key" (Some :: Some Int) --(=+:) :: (MonadIO actM, ReqParam p) => QueryKey -> proxy p -> ApiaryT exts ([p] : prms) actM m () -> ApiaryT exts prms actM m () -- | query exists checker. -- --
-- hasQuery q = query q (Check :: Check ()) --hasQuery :: MonadIO actM => QueryKey -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | get existance of key only query parameter. since v0.17.0. switchQuery :: Monad actM => QueryKey -> ApiaryT exts (Bool : prms) actM m () -> ApiaryT exts prms actM m () -- | check whether to exists specified header or not. since 0.6.0.0. hasHeader :: Monad actM => HeaderName -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | check whether to exists specified valued header or not. since 0.6.0.0. eqHeader :: Monad actM => HeaderName -> ByteString -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | filter by headers up to 100 entries. since 0.6.0.0. headers :: Monad actM => HeaderName -> ApiaryT exts ([ByteString] : prms) actM m () -> ApiaryT exts prms actM m () -- | filter by header and get first. since 0.6.0.0. header :: Monad actM => HeaderName -> ApiaryT exts (ByteString : prms) actM m () -> ApiaryT exts prms actM m () -- | low level header filter. since 0.6.0.0. header' :: (Strategy w, Monad actM) => (forall x. Proxy x -> w x) -> (Header -> Bool) -> Maybe Html -> ApiaryT exts (SNext w prms ByteString) actM m () -> ApiaryT exts prms actM m () -- | require Accept header and set response Content-Type. since 0.16.0. accept :: Monad actM => ContentType -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | filter by ssl accessed. since 0.1.0.0. ssl :: Monad actM => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | filter by HTTP method using StdMethod. since 0.1.0.0. -- | Deprecated: use method stdMethod :: Monad actM => Method -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | match all subsequent path. since 0.15.0. -- | Deprecated: use greedy filter [capture|/**|] or use restPath. anyPath :: (Monad m, Monad actM) => ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () instance IsString QueryKey module Control.Monad.Apiary -- | most generic Apiary monad. since 0.8.0.0. data ApiaryT exts prms actM m a type EApplication e m = Extensions e -> m Application server :: Monad m => (Application -> m a) -> EApplication [] m -> m a serverWith :: Monad m => Initializer m [] exts -> (Application -> m a) -> (EApplication exts m) -> m a runApiaryT :: (Monad actM, Monad m) => (forall b. actM b -> IO b) -> ApiaryConfig -> ApiaryT exts [] actM m () -> EApplication exts m runApiary :: Monad m => ApiaryConfig -> ApiaryT exts [] IO m () -> EApplication exts m apiaryConfig :: Monad actM => ApiaryT exts prms actM m ApiaryConfig apiaryExt :: (Has e exts, Monad actM) => proxy e -> ApiaryT exts prms actM m e -- | splice ActionT ApiaryT. action :: Monad actM => Fn prms (ActionT exts actM ()) -> ApiaryT exts prms actM m () -- | like action. but not apply arguments. since 0.8.0.0. action' :: Monad actM => (SList prms -> ActionT exts actM ()) -> ApiaryT exts prms actM m () middleware :: Monad actM => Middleware -> ApiaryT exts prms actM m () -- | API document group. since 0.12.0.0. -- -- only top level group recognized. group :: Text -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | 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 exts prms actM m () -> ApiaryT exts prms actM m () -- | add user defined precondition. since 0.13.0. precondition :: Html -> ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () noDoc :: ApiaryT exts prms actM m () -> ApiaryT exts prms actM m () -- | construct Html as route parameter. since 0.13.0. rpHtml :: Html -> Int -> Html -- | execute action before main action. since 0.4.2.0 -- | Deprecated: use action' actionWithPreAction :: Monad actM => (SList xs -> ActionT exts actM a) -> Fn xs (ActionT exts actM ()) -> ApiaryT exts xs actM m () module Web.Apiary.Heroku data Heroku data HerokuConfig HerokuConfig :: Int -> String -> Maybe String -> HerokuConfig defaultPort :: HerokuConfig -> Int herokuExecutableName :: HerokuConfig -> String herokuAppName :: HerokuConfig -> Maybe String -- | use this function instead of server in heroku app. since 0.17.0. -- --
-- server (run 3000) . runApiary def $ foo ---- -- to -- --
-- heroku run def . runApiary def $ foo ---- -- this function provide: -- --
-- serverWith exts (run 3000) . runApiary def $ foo ---- -- to -- --
-- herokuWith exts run def . runApiary def $ foo --herokuWith :: MonadIO m => Initializer m '[Heroku] exts -> (Int -> Application -> m a) -> HerokuConfig -> EApplication exts m -> m a getHerokuEnv :: Has Heroku exts => Text -> Extensions exts -> IO (Maybe Text) getHerokuEnv' :: Text -> Heroku -> IO (Maybe Text) instance Default HerokuConfig 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" ---- | Deprecated: no longer maintained act :: QuasiQuoter