Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active May 18, 2020 08:38
Show Gist options
  • Save adamw/7dcc3b113b65f32cefd235129340b904 to your computer and use it in GitHub Desktop.
Save adamw/7dcc3b113b65f32cefd235129340b904 to your computer and use it in GitHub Desktop.
val getPetWithLogic =
secureEndpoint
.get
.in(query[UUID]("id").description("The id of the pet to find"))
.out(jsonBody[Pet])
.description("Finds a pet by id")
.serverLogic {
case (user, id) =>
findPetForUser(user, id).map {
case Right(Some(pet)) => Right(pet)
case Right(None) => Left(Error("Not found", StatusCode.NotFound))
case Left(error) => Left(error)
}
}
val addPetWithLogic =
secureEndpoint
.post
.in(jsonBody[Pet])
.description("Adds a pet")
.serverLogic((addPetToUser _).tupled)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment