We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 25cb688 commit 10aa133Copy full SHA for 10aa133
src/Main.hs
@@ -7,6 +7,7 @@
7
module Main where
8
9
import Data.Aeson (ToJSON)
10
+import Data.Foldable (find)
11
import Data.Proxy (Proxy(Proxy))
12
import Data.Time (Day, fromGregorian)
13
import GHC.Generics (Generic)
@@ -65,8 +66,14 @@ users =
65
66
usersIndex :: Handler [User]
67
usersIndex = pure users
68
69
+matchesUsername :: String -> User -> Bool
70
+matchesUsername uname = (uname ==) . username
71
+
72
usersShow :: String -> Handler User
-usersShow _uname = _
73
+usersShow uname =
74
+ case find (matchesUsername uname) users of
75
+ Nothing -> _
76
+ Just user -> pure user
77
78
usersServer :: Server UsersAPI
79
usersServer = usersIndex :<|> usersShow
0 commit comments