git.iko.soy/typeable/servant
on master help sign in
make sure the path matches exactly in GET, and check that the client actually made a GET request
85f883fAlp Mestanogullari
src/Soenke.hs+9−7
@@ -64,13 +64,15 @@ class HasServer layout where
64
64
65instance ToJSON result => HasServer (Get result) where
65instance ToJSON result => HasServer (Get result) where
66 type Server (Get result) = (EitherT (Int, String) IO result)
66 type Server (Get result) = (EitherT (Int, String) IO result)
67− route Proxy action _request = do
67+ route Proxy action request
68+ | null (pathInfo request) && requestMethod request == methodGet = do
68− e <- runEitherT action
69+ e <- runEitherT action
69− return $ Just $ case e of
70+ return $ Just $ case e of
70− Right output ->
71+ Right output ->
71− responseLBS ok200 [("Content-Type", "application/json")] (encode output)
72+ responseLBS ok200 [("Content-Type", "application/json")] (encode output)
72− Left (status, message) ->
73+ Left (status, message) ->
73− responseLBS (mkStatus status (cs message)) [] (cs message)
74+ responseLBS (mkStatus status (cs message)) [] (cs message)
75+ | otherwise = return Nothing
74
76
75instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
77instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
76 type Server (path :> sublayout) = path :> (Server sublayout)
78 type Server (path :> sublayout) = path :> (Server sublayout)