Yesod でリソース用の REST API を作成しています。指定されたリソースを作成しようとする POST メソッドがあり、成功した場合は 201 と新しく作成されたリソースの ID を返します。例えば、
postResourceR :: Handler String
postResourceR = do
id <- runDB $ insert Resource
sendResponseStatus status201 id -- DOES NOT COMPILE
これは私が得るエラーです。これは十分に明白です:
No instance for (ToTypedContent (Key Resource))
arising from use of 'sendResponseStatus'
の何かが欲しいのはわかっていますが、Database.Persist.ClassToTypedContent
の からそれを取得する方法が見つかりません。Key
どんな助けでも大歓迎です。
編集:
実際のリソースの定義は次のとおりです。
Notification
title Text
content Text
icon Text Maybe
action Text Maybe
created UTCTime
updated UTCTime
deriving Show