Created
June 28, 2009 01:08
-
-
Save tjweir/137175 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* api helpers | |
*/ | |
implicit def boxNodeSeqToNodeSeq(in: Box[NodeSeq]): NodeSeq = { | |
in match { | |
case Full(n) => n | |
case Failure(msg, _, _) => <error>{msg}</error> | |
case _ => <error></error> | |
} | |
} | |
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) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment