on master help sign in
Utils.Link documentation cleanup
commitc1ab495a7a96929d40ce119428674cadccc71164 authorChristian Marie <christian@ponies.io> dateThu 29 Jan 2015, 11:23 (12 years ago) parent2a91686
1 file changed+10−11
src/Servant/Utils/Links.hs+10−11
src/Servant/Utils/Links.hs+10−11
@@ -25,23 +25,22 @@
2525-- >>> let api = Proxy :: Proxy API
2626--
2727-- It is possible to generate links that are guaranteed to be within 'API' with
28−-- 'safeLink'.
29−--
30−-- The first argument to 'safeLink' is a symbol representing the endpoint you
31−-- would like to point to. This will need to end in a verb like Get, or Post.
28+-- 'safeLink'. The first argument to 'safeLink' is a type representing the
29+-- endpoint you would like to point to. This will need to end in a verb like
30+-- Get, or Post. The second argument is the API in which you would like to
31+-- ensure the endpoint is within. Further arguments may or may not be required
32+-- depending on the type of the endpoint. If everything lines up you will get a
33+-- 'URI' out the other end.
3234--
3335-- You may omit 'QueryParam's and the like should you not want to provide them,
34−-- but certain other types like 'Capture' must be included.
35−--
36+-- but types which form part of the URL path like 'Capture' must be included.
3637-- The reason you may want to omit 'QueryParam's is that safeLink is a bit
3738-- magical: if parameters are included that could take input it will return a
38−-- function that accepts that input and generates a link.
39−--
40−-- This is best shown with an example. Here, a link is generated with no
41−-- parameters:
39+-- function that accepts that input and generates a link. This is best shown
40+-- with an example. Here, a link is generated with no parameters:
4241--
4342-- >>> let hello = Proxy :: Proxy ("hello" :> Get Int)
44−-- >>> print $ safeLink hello api
43+-- >>> print (safeLink hello api :: URI)
4544-- hello
4645--
4746-- If the API has an endpoint with parameters then we can generate links with