-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | A family of combinators for defining webservices APIs -- @package servant @version 0.2.2 module Servant.Common.Text -- | For getting values from url captures and query string parameters class FromText a fromText :: FromText a => Text -> Maybe a -- | For putting values in paths and query string parameters class ToText a toText :: ToText a => a -> Text instance ToText Float instance FromText Float instance ToText Double instance FromText Double instance ToText Integer instance FromText Integer instance ToText Word64 instance FromText Word64 instance ToText Word32 instance FromText Word32 instance ToText Word16 instance FromText Word16 instance ToText Word8 instance FromText Word8 instance ToText Word instance FromText Word instance ToText Int64 instance FromText Int64 instance ToText Int32 instance FromText Int32 instance ToText Int16 instance FromText Int16 instance ToText Int8 instance FromText Int8 instance ToText Int instance FromText Int instance ToText Bool instance FromText Bool instance ToText String instance FromText String instance ToText Text instance FromText Text module Servant.API.Raw -- | Endpoint for plugging in your own Wai Applications. -- -- The given Application will get the request as received by the -- server, potentially with a modified (stripped) pathInfo if -- the Application is being routed with :>. -- -- In addition to just letting you plug in your existing WAI -- Applications, this can also be used with -- serveDirectory to serve static files stored in a particular -- directory on your filesystem, or to serve your API's documentation -- with serveDocumentation. data Raw module Servant.API.Put -- | Endpoint for PUT requests, usually used to update a ressource. The -- type a is the type of the response body that's returned. -- -- Example: -- --
-- -- PUT /books/:isbn -- -- with a Book as request body, returning the updated Book -- type MyApi = "books" :> Capture "isbn" Text :> ReqBody Book :> Put Book --data Put a instance Typeable Put module Servant.API.Delete -- | Combinator for DELETE requests. -- -- Example: -- --
-- -- DELETE /books/:isbn -- type MyApi = "books" :> Capture "isbn" Text :> Delete --data Delete instance Typeable Delete module Servant.API.Post -- | Endpoint for POST requests. The type variable represents the type of -- the response body (not the request body, use ReqBody for that). -- -- Example: -- --
-- -- POST /books -- -- with a JSON encoded Book as the request body -- -- returning the just-created Book -- type MyApi = "books" :> ReqBody Book :> Post Book --data Post a instance Typeable Post module Servant.API.Get -- | Endpoint for simple GET requests. Serves the result as JSON. -- -- Example: -- --
-- type MyApi = "books" :> Get [Book] --data Get a instance Typeable Get module Servant.API.MatrixParam -- | Lookup the value associated to the sym matrix string -- parameter and try to extract it as a value of type a. -- -- Example: -- --
-- -- /books;author=<author name> -- type MyApi = "books" :> MatrixParam "author" Text :> Get [Book] --data MatrixParam sym a -- | Lookup the values associated to the sym matrix string -- parameter and try to extract it as a value of type [a]. This -- is typically meant to support matrix string parameters of the form -- param[]=val1;param[]=val2 and so on. Note that servant -- doesn't actually require the []s and will fetch the values -- just fine with param=val1;param=val2, too. -- -- Example: -- --
-- -- /books;authors[]=<author1>;authors[]=<author2>;... -- type MyApi = "books" :> MatrixParams "authors" Text :> Get [Book] --data MatrixParams sym a -- | Lookup a potentially value-less matrix string parameter with boolean -- semantics. If the param sym is there without any value, or if -- it's there with value "true" or "1", it's interpreted as True. -- Otherwise, it's interpreted as False. -- -- Example: -- --
-- -- /books;published -- type MyApi = "books" :> MatrixFlag "published" :> Get [Book] --data MatrixFlag sym module Servant.API.ReqBody -- | Extract the request body as a value of type a. -- -- Example: -- --
-- -- POST /books -- type MyApi = "books" :> ReqBody Book :> Post Book --data ReqBody a module Servant.API.QueryParam -- | Lookup the value associated to the sym query string parameter -- and try to extract it as a value of type a. -- -- Example: -- --
-- -- /books?author=<author name> -- type MyApi = "books" :> QueryParam "author" Text :> Get [Book] --data QueryParam sym a -- | Lookup the values associated to the sym query string -- parameter and try to extract it as a value of type [a]. This -- is typically meant to support query string parameters of the form -- param[]=val1¶m[]=val2 and so on. Note that servant -- doesn't actually require the []s and will fetch the values -- just fine with param=val1¶m=val2, too. -- -- Example: -- --
-- -- /books?authors[]=<author1>&authors[]=<author2>&... -- type MyApi = "books" :> QueryParams "authors" Text :> Get [Book] --data QueryParams sym a -- | Lookup a potentially value-less query string parameter with boolean -- semantics. If the param sym is there without any value, or if -- it's there with value "true" or "1", it's interpreted as True. -- Otherwise, it's interpreted as False. -- -- Example: -- --
-- -- /books?published -- type MyApi = "books" :> QueryFlag "published" :> Get [Book] --data QueryFlag sym module Servant.API.Header -- | Extract the given header's value as a value of type a. -- -- Example: -- --
-- newtype Referer = Referer Text -- deriving (Eq, Show, FromText, ToText) -- -- -- GET /view-my-referer -- type MyApi = "view-my-referer" :> Header "from" Referer :> Get Referer --data Header sym a module Servant.API.Capture -- | Capture a value from the request path under a certain type a. -- -- Example: -- --
-- -- GET /books/:isbn -- type MyApi = "books" :> Capture "isbn" Text :> Get Book --data Capture sym a module Servant.API.Alternative -- | Union of two APIs, first takes precedence in case of overlap. -- -- Example: -- --
-- type MyApi = "books" :> Get [Book] -- GET /books -- :<|> "books" :> ReqBody Book :> Post Book -- POST /books --data (:<|>) a b (:<|>) :: a -> b -> (:<|>) a b module Servant.API.Sub -- | The contained API (second argument) can be found under ("/" ++ -- path) (path being the first argument). -- -- Example: -- --
-- -- GET /hello/world -- -- returning a JSON encoded World value -- type MyApi = "hello" :> "world" :> Get World --data (:>) (path :: k) a (:>) :: Proxy path -> a -> (:>) a -- | QuasiQuoting utilities for API types. -- -- sitemap allows you to write your type in a very natural way: -- --
-- [sitemap| -- PUT hello String -> () -- POST hello/p:Int String -> () -- GET hello/?name:String Int -- |] ---- -- Will generate: -- --
-- "hello" :> ReqBody String :> Put () -- :<|> "hello" :> Capture "p" Int :> ReqBody String :> Post () -- :<|> "hello" :> QueryParam "name" String :> Get Int ---- -- Note the / before a QueryParam! module Servant.QQ -- | The sitemap QuasiQuoter. -- --
-- type API = Proxy ("hello" :> Get Int
-- :| "bye" :> QueryParam "name" String :> Post Bool)
--
-- api :: API
-- api = proxy
--
-- link1 :: Proxy ("hello" :> Get Int)
-- link1 = proxy
--
-- link2 :: Proxy ("hello" :> Delete)
-- link2 = proxy
--
-- mkLink link1 API -- typechecks, returns 'Link "/hello"'
--
-- mkLink link2 API -- doesn't typecheck
--
--
-- That is, mkLink takes two arguments, a link proxy and a
-- sitemap, and returns a Link, but only typechecks if the link
-- proxy is a valid link, and part of the sitemap.
--
-- N.B.: mkLink assumes a capture matches any string
-- (without slashes).
module Servant.Utils.Links
-- | A safe link datatype. The only way of constructing a Link is
-- using mkLink, which means any Link is guaranteed to be
-- part of the mentioned API.
data Link
-- | The 'ValidLinkIn f s' constraint holds when s is an API that
-- contains f, and f is a link.
class ValidLinkIn f s
mkLink :: ValidLinkIn f s => f -> s -> Link
class VLinkHelper f
vlh :: VLinkHelper f => proxy f -> String
instance Show Link
instance VLinkHelper (Post x)
instance VLinkHelper (Get x)
instance (KnownSymbol s, VLinkHelper e) => VLinkHelper (s :> e)
instance (IsElem f s ~ 'True, IsLink f ~ 'True, VLinkHelper f) => ValidLinkIn f s
module Servant.API