I’m currently working on a Rest Api using Lift as Framework.
Most of the requests are using Json as return type which works fine:
serve ("api" / "item" prefix {
case _ :: Nil JsonGet _ => {
if (checkKey(S.params("api_key").mkString)) Item.newItem(S.params("item_id").mkString, S.params("api_key").mkString)
}
})
Now i want to add a function which returns plain html which is stored in a mysql db. So basicly i want to return a String back to the Resthelper.
I tried something like this but it didn’t compile:
serve {
case "itemDesc" :: itemnum :: _ => {
Item.getDescription(itemnum)
}
}
Maybe I’m stupid but i couldn’t find anything in the Lift “Cookbook”
Update:
serve {
case "itemDesc" :: AsInt(itemnum) :: _ XmlGet _ => {
Item.getDescription(itemnum)
}
}
I tried this to fool lift by selling html as XML. It compiled but didn’t work at the end.
Obviously it’s not possible to respond a normal String back from a RestHelper.
Thanks for your help
You have to give back
Box[LiftResponse].So In that case It’d be
Full(PlainTextResponse(Item.getDescription(itemnum)).I would also add implicit conversion from
LiftResponse -> Box[LiftResponse]