olon.http.rest

package olon.http.rest

Members list

Type members

Classlikes

trait Continuation

Attributes

Supertypes
class Object
trait Matchable
class Any
case class ContinuationKey(path: ParsePath, reqType: RequestType)

Attributes

Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all

Attributes

Supertypes
trait LazyLoggable
trait HasCalcDefaultValue[HashMap[ContinuationKey, Continuation]]
trait PSettableValueHolder[HashMap[ContinuationKey, Continuation]]
trait SettableValueHolder
trait Settable
trait PValueHolder[HashMap[ContinuationKey, Continuation]]
trait ValueHolder
class Object
trait Matchable
class Any
Show all
Self type
case object JsonSelect extends JsonXmlSelect

The Type for JSON

The Type for JSON

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
JsonSelect.type
trait JsonXmlAble

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 Object
trait Matchable
class Any
sealed trait JsonXmlSelect

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 Object
trait Matchable
class Any
Known subtypes
object JsonSelect
object XmlSelect
final class ListServeMagic(list: List[String])

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 Object
trait Matchable
class 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 Object
trait Matchable
class Any
Self type
trait RestHelper extends DispatchPF

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
trait PartialFunction[Req, () => Box[LiftResponse]]
trait Req => () => Box[LiftResponse]
class Object
trait Matchable
class Any
trait XMLApiHelper

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 Object
trait Matchable
class Any
case object XmlSelect extends JsonXmlSelect

The type for XML

The type for XML

Attributes

Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Self type
XmlSelect.type