olon.http.rest
Members list
Type members
Classlikes
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Supertypes
-
trait LazyLoggableclass AnyVar[HashMap[ContinuationKey, Continuation], SessionVar[HashMap[ContinuationKey, Continuation]]]trait AnyVarTrait[HashMap[ContinuationKey, Continuation], SessionVar[HashMap[ContinuationKey, Continuation]]]trait SettableValueHoldertrait Settabletrait ValueHolderclass Objecttrait Matchableclass AnyShow all
- Self type
-
ContinuationsStore.type
The Type for JSON
A trait that can be mixed into an class (probably a case class) so that the class can be converted automatically into JSON or XML
A trait that can be mixed into an class (probably a case class) so that the class can be converted automatically into JSON or XML
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
This trait is part of the ADT that allows the choice between
This trait is part of the ADT that allows the choice between
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object JsonSelectobject XmlSelect
Do some magic to prefix path patterns with a single List
Do some magic to prefix path patterns with a single List
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Provides a generic way of sending asynchronous response to HTTP clients. If the underlying web container does not support continuations the asynchronous nature is achieved using locks.
Provides a generic way of sending asynchronous response to HTTP clients. If the underlying web container does not support continuations the asynchronous nature is achieved using locks.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RestContinuation.type
Mix this trait into a class to provide a list of REST helper methods
Mix this trait into a class to provide a list of REST helper methods
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
Mix this trait into your REST service provider to convert between different response types and a LiftResponse. You need to define the createTag method to provide a root element for your API. You may optionally override the successAttrName, operationAttrName, and/or msgAttrName defs to control the attributes that will be applied to your root element based on the return from your API.
Mix this trait into your REST service provider to convert between different response types and a LiftResponse. You need to define the createTag method to provide a root element for your API. You may optionally override the successAttrName, operationAttrName, and/or msgAttrName defs to control the attributes that will be applied to your root element based on the return from your API.
For example, the following code implements a simple API that takes a comma- separated string of integers and reduces them with various operations.
object CalculatorApi extends XmlApiHelper { // Define our root tag def createTag(contents : NodeSeq) : Elem = <api>{contents}</api> // The LiftResponses here will be converted to Box[LiftResponse] // via the putResponseInBox implicit conversion def calculator : LiftRules.DispatchPF = { case r @ Req(List("api","sum"), _, GetRequest) => () => doSum(r) case r @ Req(List("api","product"), _, GetRequest) => () => doProduct(r) case r @ Req(List("api","max"), _, GetRequest) => () => doMax(r) case r @ Req(List("api","min"), _, GetRequest) => () => doMin(r) case Req("api" :: _, _, _) => () => BadResponse() } // Define a common handler def reduceOp (operation : (Int,Int) => Int)(r : Req) : Box[Elem] = tryo { (r.param("args").map { args => <result>{args.split(",").map(_.toInt).reduceLeft(operation)}</result> }) ?~ "Missing args" } match { case Full(x) => x case f : Failure => f case Empty => Empty } // Using a return type of LiftResponse causes the canNodeToResponse // implicit to be invoked def doSum (r : Req) : LiftResponse = reduceOp(_ + _)(r) def doProduct (r : Req) : LiftResponse = reduceOp(_ * _)(r) def doMax (r : Req) : LiftResponse = reduceOp(_ max _)(r) def doMin (r : Req) : LiftResponse = reduceOp(_ min _)(r) }
With this API, the URL
http://foo.com/api/sum?args=1,2,3,4,5
would return
<api operation="sum" success="true"><result>15</result></api>
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any