Last active
May 18, 2020 08:38
-
-
Save adamw/7dcc3b113b65f32cefd235129340b904 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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