Skip to content
This repository has been archived by the owner on Feb 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #13 from kailuowang/master
Browse files Browse the repository at this point in the history
minor fixes
  • Loading branch information
kailuowang committed Dec 9, 2015
2 parents 8efe167 + 0377fe9 commit 950b6a2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions play-dsl-core/src/main/scala/com/iheart/play/dsl/Syntax.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,11 @@ trait Syntax

def process[RMT] = new processorBuilder[RMT]


implicit class DirectiveDSL[RMT: ClassTag](self: Directive[RMT]) {

def `with`(f: Filter[RMT]) = self.filter(f)

def ifEmpty[InnerT](fieldExtractor: RMT Option[InnerT]) = new Object {
case class ifEmpty[InnerT](fieldExtractor: RMT Option[InnerT]) {
def respond(alternative: Result) = {
val f: Filter[RMT] = (req, result) fieldExtractor(req.body).fold(Future.successful(alternative))(_ result)
self.`with`(f)
Expand Down Expand Up @@ -62,10 +61,9 @@ trait Syntax


case class expect[RMT: ClassTag]() {
private def directive(f: RMT Result) = Directive(f)

def respond(result: Result) = directive(_ result)
def respondJson(tr: JsValue Result)(implicit writes: Writes[RMT]) = directive(t tr(Json.toJson(t)))
def respond(f: RMT Result): Directive[RMT] = Directive(f)
def respond(result: Result): Directive[RMT] = respond(_ result)
def respondJson(tr: JsValue Result)(implicit writes: Writes[RMT]): Directive[RMT] = respond(t tr(Json.toJson(t)))
}

def from[Repr <: HList] = Extractor.apply[Repr] _
Expand Down

0 comments on commit 950b6a2

Please sign in to comment.