Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
p-zalejko committed Oct 11, 2019
1 parent e9fe16d commit 6b97497
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package com.gmail.pzalejko.myplanner.event;

import com.mongodb.client.MongoClient
import io.vertx.axle.core.Vertx
import java.util.concurrent.CompletableFuture
import java.util.concurrent.CompletionStage
import javax.inject.Inject
import javax.ws.rs.*
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response

@Path("/events")
@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -28,10 +28,12 @@ class EventController {
}

@POST
fun addNew(name: EventDto): CompletionStage<String> {
fun addNew(name: EventDto): CompletionStage<Response> {
val event = Event(name = name.name)
val addNew = service.addNew(event)
return addNew.thenCompose { d -> CompletableFuture.completedFuture("OK") }
return addNew
.thenApply(Response::ok)
.thenApply(Response.ResponseBuilder::build);
}

class EventDto {
Expand Down

0 comments on commit 6b97497

Please sign in to comment.