Skip to content

Commit

Permalink
Fixing tests and example.
Browse files Browse the repository at this point in the history
  • Loading branch information
luksow committed Jul 3, 2024
1 parent 09953c3 commit a9335d8
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions examples/src/main/scala/Service.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ object Main extends IOApp.Simple {
handleExceptions(ExceptionHandler.default()) {
handleRejections(RejectionHandler.default) {
logRequestResult() {
extractClientIP { clientIp =>
println(s"Client IP: $clientIp")
extractClientIP { _ =>
pathPrefix("api" / "beers") {
(get & parameters("pageSize".as[Int].?, "pageNumber".as[Int].?) & pathEndOrSingleSlash) {
(pageSize, pageNumber) =>
Expand All @@ -62,7 +61,15 @@ object Main extends IOApp.Simple {
}
}
} ~
(delete & pathEndOrSingleSlash & path(JavaUUID)) { id =>
(get & path(JavaUUID) & pathEndOrSingleSlash) { id =>
complete {
Option(beers.get(id)) match {
case Some(beer) => Status.Ok -> beer
case None => Status.NotFound -> "Beer not found"
}
}
} ~
(delete & path(JavaUUID) & pathEndOrSingleSlash) { id =>
complete {
IO.delay(beers.remove(id)).map(_ => Status.NoContent -> "Yes, content")
}
Expand Down

0 comments on commit a9335d8

Please sign in to comment.