make sure the path matches exactly in GET, and check that the client actually made a GET request
This commit is contained in:
parent
45a625c72c
commit
85f883f4de
1 changed files with 9 additions and 7 deletions
|
@ -64,13 +64,15 @@ class HasServer layout where
|
||||||
|
|
||||||
instance ToJSON result => HasServer (Get result) where
|
instance ToJSON result => HasServer (Get result) where
|
||||||
type Server (Get result) = (EitherT (Int, String) IO result)
|
type Server (Get result) = (EitherT (Int, String) IO result)
|
||||||
route Proxy action _request = do
|
route Proxy action request
|
||||||
e <- runEitherT action
|
| null (pathInfo request) && requestMethod request == methodGet = do
|
||||||
return $ Just $ case e of
|
e <- runEitherT action
|
||||||
Right output ->
|
return $ Just $ case e of
|
||||||
responseLBS ok200 [("Content-Type", "application/json")] (encode output)
|
Right output ->
|
||||||
Left (status, message) ->
|
responseLBS ok200 [("Content-Type", "application/json")] (encode output)
|
||||||
responseLBS (mkStatus status (cs message)) [] (cs message)
|
Left (status, message) ->
|
||||||
|
responseLBS (mkStatus status (cs message)) [] (cs message)
|
||||||
|
| otherwise = return Nothing
|
||||||
|
|
||||||
instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
|
instance (KnownSymbol path, HasServer sublayout) => HasServer (path :> sublayout) where
|
||||||
type Server (path :> sublayout) = path :> (Server sublayout)
|
type Server (path :> sublayout) = path :> (Server sublayout)
|
||||||
|
|
Loading…
Reference in a new issue