ant*_*ice 1 haskell yesod haskell-persistent
我正在为Yesod中的资源编写REST API.我有一个POST方法应该尝试创建给定的资源,如果成功返回201和新创建的资源的ID.例如,
postResourceR :: Handler String
postResourceR = do
id <- runDB $ insert Resource
sendResponseStatus status201 id -- DOES NOT COMPILE
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误,这很简单:
No instance for (ToTypedContent (Key Resource))
arising from use of 'sendResponseStatus'
Run Code Online (Sandbox Code Playgroud)
我知道我想要的东西ToTypedContent,但我找不到任何方法从KeyDatabase.Persist.Class中获取它.任何帮助将不胜感激.
编辑:
这是实际资源的定义:
Notification
title Text
content Text
icon Text Maybe
action Text Maybe
created UTCTime
updated UTCTime
deriving Show
Run Code Online (Sandbox Code Playgroud)