net.liftweb.http.rest.RestHelper

trait RestHelper

trait RestHelper

 extends PartialFunction[Req, () => Box[LiftResponse]]


Mix this trait into a class to provide a lost of REST helper methods


Source: RestHelper.scala(30)

Nested Classes

AutoJsonXmlAble, JsonBody, JsonTest, TestDelete, TestGet, TestPost, TestPut, TestReq, XmlBody, XmlTest,

 Fields

->.. protected object ->
Extract a Pair using the same syntax that you use to make a Pair


 extends ScalaObject
Delete.. protected object Delete
An extractor that tests the request to see if it's a DELETE and if it is, the path and the request are extracted [details]
It can be used as:
case "api" :: id :: _ Delete req => ...

or
case Delete("api" :: id :: _, req) => ...



 extends ScalaObject
Get.. protected object Get
An extractor that tests the request to see if it's a GET and if it is, the path and the request are extracted [details]
It can be used as:
case "api" :: id :: _ Get req => ...

or
case Get("api" :: id :: _, req) => ...

*


 extends ScalaObject
JsonDelete.. protected lazy val JsonDelete TestDelete with JsonTest
JsonGet.. protected lazy val JsonGet TestGet with JsonTest
JsonPost.. protected lazy val JsonPost TestPost[JValue] with JsonTest with JsonBody
JsonPut.. protected lazy val JsonPut TestPut[JValue] with JsonTest with JsonBody
JsonReq.. protected lazy val JsonReq TestReq with JsonTest
Post.. protected object Post
An extractor that tests the request to see if it's a POST and if it is, the path and the request are extracted [details]
It can be used as:
case "api" :: id :: _ Post req => ...

or
case Post("api" :: id :: _, req) => ...



 extends ScalaObject
Put.. protected object Put
An extractor that tests the request to see if it's a PUT and if it is, the path and the request are extracted [details]
It can be used as:
case "api" :: id :: _ Put req => ...

or
case Put("api" :: id :: _, req) => ...



 extends ScalaObject
XmlDelete.. protected lazy val XmlDelete TestDelete with XmlTest
XmlGet.. protected lazy val XmlGet TestGet with XmlTest
XmlPost.. protected lazy val XmlPost TestPost[Elem] with XmlTest with XmlBody
XmlPut.. protected lazy val XmlPut TestPut[Elem] with XmlTest with XmlBody
XmlReq.. protected lazy val XmlReq TestReq with XmlTest
convertAutoJsonXmlAble.. protected implicit lazy val convertAutoJsonXmlAble PartialFunction[(JsonXmlSelect, AutoJsonXmlAble, Req), LiftResponse]
convertJsonXmlAble.. protected implicit lazy val convertJsonXmlAble PartialFunction[(JsonXmlSelect, JsonXmlAble, Req), LiftResponse]
formats.. protected implicit def formats
Return the implicit Formats instance for JSON conversion
Formats

 Methods

!=.. final def !=(arg0 : Object) Boolean AnyRef
!=.. final def !=(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Any) Boolean Any
==.. final def ==(arg0 : Object) Boolean AnyRef
andThen.. override def andThen[C](arg0 : (B) => C) PartialFunction[A, C] PartialFunction
apply.. def apply(in : Req)
Apply the Rest helper
() => Box[LiftResponse]
asInstanceOf.. final def asInstanceOf[T0] T0 Any
auto.. protected def auto(in : Box[Any])
Wrap a Box of anything for autoconversion to JSON or XML
Box[AutoJsonXmlAble]
auto.. protected def auto(in : Any)
wrap anything for autoconversion to JSON or XML
Box[AutoJsonXmlAble]
boxFuncToResp.. protected implicit def boxFuncToResp[T](in : () => Box[T])(implicit c : (T) => LiftResponse)
Turn a () => Box[T] into the return type expected by DispatchPF [details]
Note that this method will return messages from Failure() and return codes and messages from ParamFailure[Int[(msg, _, _, code)
() => Box[LiftResponse]
boxToResp.. protected implicit def boxToResp[T](in : Box[T])(implicit c : (T) => LiftResponse)
Turn a Box[T] into the return type expected by DispatchPF [details]
Note that this method will return messages from Failure() and return codes and messages from ParamFailure[Int[(msg, _, _, code)
() => Box[LiftResponse]
clone.. protected def clone Object AnyRef
compose.. def compose[A](arg0 : (A) => T1) (A) => R Function1
emptyToResp.. protected def emptyToResp(eb : EmptyBox) Box[LiftResponse]
eq.. final def eq(arg0 : Object) Boolean AnyRef
equals.. def equals(arg0 : Any) Boolean AnyRef
finalize.. protected def finalize Unit AnyRef
getClass.. final def getClass Class[Any] AnyRef
hashCode.. def hashCode Int AnyRef
isDefinedAt.. def isDefinedAt(in : Req)
Is the Rest helper defined for a given request
Boolean
isInstanceOf.. final def isInstanceOf[T0] Boolean Any
jsExpToResp.. implicit def jsExpToResp(in : JsExp)
Convert a JsExp to a LiftResponse
LiftResponse
jsonResponse_?.. protected def jsonResponse_?(in : Req)
Will the request accept a JSON response? Yes if the Accept header contains "application/json" or the Accept header is missing or contains "star/star" and the suffix is "json" [details]
Override this method to provide your own logic
Boolean
jsonToResp.. implicit def jsonToResp(in : JValue)
Convert a JValue to a LiftResponse
LiftResponse
jxSel.. implicit def jxSel(req : Req)
A function that chooses JSON or XML based on the request [details]
. Use with serveType
Box[JsonXmlSelect]
ne.. final def ne(arg0 : Object) Boolean AnyRef
nodeToResp.. protected implicit def nodeToResp(in : Node)
Convert a Node to an XmlResponse
LiftResponse
notify.. final def notify Unit AnyRef
notifyAll.. final def notifyAll Unit AnyRef
optionFuncToResp.. protected implicit def optionFuncToResp[T](in : () => Option[T])(implicit c : (T) => LiftResponse)
Turn an Option[T] into the return type expected by DispatchPF
() => Box[LiftResponse]
optionToResp.. protected implicit def optionToResp[T](in : Option[T])(implicit c : (T) => LiftResponse)
Turn an Option[T] into the return type expected by DispatchPF
() => Box[LiftResponse]
orElse.. def orElse[A1 <: A, B1 >: B](arg0 : PartialFunction[A1, B1]) PartialFunction[A1, B1] PartialFunction
serve.. protected def serve(handler : PartialFunction[Req, () => Box[LiftResponse]])
Add request handlers
Unit
serveJx.. protected def serveJx[T](pf : PartialFunction[Req, Box[T]])(implicit cvt : PartialFunction[T])
Serve a request returning either JSON or XML [details]
@parama pf -- a Partial Function that converts the request into an intermediate response.
param
cvt - -- convert the intermediate response to a LiftResponse based on the request being for XML or JSON. If T is JsonXmlAble, there are built-in converters. Further, you can return auto(thing) and that will invoke built-in converters as well. The built-in converters use Lift JSON's Extraction.decompose to convert the object into JSON and then Xml.toXml() to convert to XML.
Unit
serveJxa.. protected def serveJxa(pf : PartialFunction[Req, Box[Any]])
Serve a request returning either JSON or XML [details]
@parama pf -- a Partial Function that converts the request into Any (note that the response must be convertable into JSON vis Lift JSON Extraction.decompose
Unit
serveType.. protected def serveType[T, SelectType](selection : (Req) => Box[SelectType])(pf : PartialFunction[Req, Box[T]])(implicit cvt : PartialFunction[(SelectType, T, Req), LiftResponse])
Serve a given request by determining the request type, computing the response and then converting the response to the given type (e [details]
g., JSON or XML).

param
cvt - -- a function that converts from the response type to a the appropriate LiftResponse based on the selected response type.
selection - -- a function that determines the response type based on the Req. @parama pf -- a PartialFunction that converts the request to a response type (e.g., a case class that contains the response).
Unit
suplimentalJsonResponse_?.. protected def suplimentalJsonResponse_?(in : Req)
If there are additional custom rules (e [details]
g., looking at query parameters) you can override this method which is consulted if the other rules in jsonResponse_? fail
Boolean
suplimentalXmlResponse_?.. protected def suplimentalXmlResponse_?(in : Req)
If there are additional custom rules (e [details]
g., looking at query parameters) you can override this method which is consulted if the other rules in xmlResponse_? fail
Boolean
synchronized.. final def synchronized[T0](arg0 : T0) T0 AnyRef
thingToResp.. protected implicit def thingToResp[T](in : T)(implicit c : (T) => LiftResponse)
Turn T into the return type expected by DispatchPF as long as we can convert T to a LiftResponse
() => Box[LiftResponse]
toString.. override def toString String Function1
wait.. final def wait(arg0 : Long, arg1 : Int) Unit AnyRef
wait.. final def wait Unit AnyRef
wait.. final def wait(arg0 : Long) Unit AnyRef
xmlResponse_?.. protected def xmlResponse_?(in : Req)
Will the request accept an XML response? Yes if the Accept header contains "text/xml" or the Accept header is missing or contains "star/star" and the suffix is "xml" [details]
Override this method to provide your own logic
Boolean
Copyright (c) 2006-2010 WorldWide Conferencing, LLC. All Rights Reserved.