File tree Expand file tree Collapse file tree 2 files changed +6
-1
lines changed
Expand file tree Collapse file tree 2 files changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ executable server
1010 main-is : Main.hs
1111 build-depends : base ^>= 4.12.0.0
1212 , aeson
13+ , mtl
1314 , servant-server
1415 , time
1516 , wai
Original file line number Diff line number Diff line change 66
77module Main where
88
9+ import Control.Monad.Error.Class
10+ ( throwError
11+ )
912import Data.Aeson (ToJSON )
1013import Data.Foldable (find )
1114import Data.Proxy (Proxy (Proxy ))
@@ -21,6 +24,7 @@ import Servant
2124 , Handler
2225 , JSON
2326 , Server
27+ , err404
2428 , serve
2529 )
2630
@@ -72,7 +76,7 @@ matchesUsername uname = (uname ==) . username
7276usersShow :: String -> Handler User
7377usersShow uname =
7478 case find (matchesUsername uname) users of
75- Nothing -> _
79+ Nothing -> throwError err404
7680 Just user -> pure user
7781
7882usersServer :: Server UsersAPI
You can’t perform that action at this time.
0 commit comments