Skip to content

Commit

Permalink
Fixing route.when (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianKirmaier authored Dec 15, 2023
1 parent be15156 commit 2b8a136
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

### 0.2.8
#### Changes
* Fixed parts of the `Route.when` api, which had unexpected argument types.

### 0.2.7 (December 8, 2023)

#### Improvements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,15 @@ trait Route {
val r2: FXFuture[Response] = if(condResult) _then(r) else null
r2
})
def when(cond: java.util.function.Function[Request, FXFuture[java.lang.Boolean]], _then: Response): Route = and(r => {
cond.apply(r).map(condResult => if(condResult) _then else null)
})
def when(cond: Predicate[Request], _then: Route, _else: Route): Route = and(r => {
if(cond.test(r)) _then(r) else _else(r)
})

def when(cond: java.util.function.Function[Request, FXFuture[java.lang.Boolean]], _then: Route): Route = and(r => {
cond.apply(r).flatMap(condResult => if (condResult) _then(r) else null)
})

def when(cond: java.util.function.Function[Request, FXFuture[java.lang.Boolean]], _then: Route, _else: Route): Route = and(r => {
cond.apply(r).flatMap(condResult => if (condResult) _then(r) else _else(r))
})
}

0 comments on commit 2b8a136

Please sign in to comment.