@@ -65,9 +65,12 @@ import Servant.API
6565 NoContent (NoContent), PlainText, Post, QueryFlag, QueryParam,
6666 QueryParams, Raw, ReqBody, StdMethod (GET), ToHttpApiData (..), UVerb, Union,
6767 WithStatus (WithStatus), addHeader)
68+import Servant.API.Generic
6869import Servant.Client
70+import Servant.Client.Generic
6971import qualified Servant.Client.Core.Auth as Auth
7072import Servant.Server
73+import Servant.Server.Generic
7174import Servant.Server.Experimental.Auth
7275import Servant.Test.ComprehensiveAPI
7376
@@ -107,6 +110,16 @@ carol = Person "Carol" 17
107110
108111type TestHeaders = '[Header "X-Example1" Int, Header "X-Example2" String]
109112
113+data RecordRoutes mode = RecordRoutes
114+ { version :: mode :- "version" :> Get '[JSON] Int
115+ , echo :: mode :- "echo" :> Capture "string" String :> Get '[JSON] String
116+ , otherRoutes :: mode :- "other" :> NamedRoutes OtherRoutes
117+ } deriving Generic
118+
119+data OtherRoutes mode = OtherRoutes
120+ { something :: mode :- "something" :> Get '[JSON] [String]
121+ } deriving Generic
122+
110123type Api =
111124 Get '[JSON] Person
112125 :<|> "get" :> Get '[JSON] Person
@@ -141,6 +154,7 @@ type Api =
141154 UVerb 'GET '[PlainText] '[WithStatus 200 Person,
142155 WithStatus 301 Text]
143156 :<|> "uverb-get-created" :> UVerb 'GET '[PlainText] '[WithStatus 201 Person]
157+ :<|> NamedRoutes RecordRoutes
144158
145159
146160api :: Proxy Api
@@ -192,7 +206,8 @@ getRoot
192206 :<|> getRedirectWithCookie
193207 :<|> EmptyClient
194208 :<|> uverbGetSuccessOrRedirect
195− :<|> uverbGetCreated = client api
209+ :<|> uverbGetCreated
210+ :<|> recordRoutes = client api
196211
197212server :: Application
198213server = serve api (
@@ -229,6 +244,13 @@ server = serve api (
229244 then respond (WithStatus @301 ("redirecting" :: Text))
230245 else respond (WithStatus @200 alice ))
231246 :<|> respond (WithStatus @201 carol)
247+ :<|> RecordRoutes
248+ { version = pure 42
249+ , echo = pure
250+ , otherRoutes = OtherRoutes
251+ { something = pure ["foo", "bar", "pweet"]
252+ }
253+ }
232254 )
233255
234256type FailApi =