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
|
||||||
|
| null (pathInfo request) && requestMethod request == methodGet = do
|
||||||
e <- runEitherT action
|
e <- runEitherT action
|
||||||
return $ Just $ case e of
|
return $ Just $ case e of
|
||||||
Right output ->
|
Right output ->
|
||||||
responseLBS ok200 [("Content-Type", "application/json")] (encode output)
|
responseLBS ok200 [("Content-Type", "application/json")] (encode output)
|
||||||
Left (status, message) ->
|
Left (status, message) ->
|
||||||
responseLBS (mkStatus status (cs message)) [] (cs 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