/** * api helpers */ implicit def boxNodeSeqToNodeSeq(in: Box[NodeSeq]): NodeSeq = { in match { case Full(n) => n case Failure(msg, _, _) => {msg} case _ => } } implicit def tupleSeqNodeToResponse(in: (String, Seq[Node])): LiftResponse = { buildResponse(true, in._1, Empty, in._2) } implicit def putResponseInBox(in: LiftResponse): Box[LiftResponse] = Full(in) def buildResponse(success: Boolean, rootname: String, msg: Box[NodeSeq], body: NodeSeq): LiftResponse = { XmlResponse( wrapXmlBody(rootname, body) ) } def wrapXmlBody(in: String, elems: NodeSeq): Elem = { Elem(null,in,Null,TopScope,elems:_*) } /** * The attribute name for success */ def successAttrName: String = "success" /** * The attribute name for operation */ def operationAttrName: String = "operation" /** * The attribute name for any msg attribute */ def msgAttrName: String = "msg" protected def operation: Option[NodeSeq] = (for (req <- S.request) yield req.path.partPath match { case _ :: name :: _ => name case _ => "" }).map(Text)