Last active
May 18, 2020 08:28
-
-
Save adamw/a58a25a074c49b6776fb19319bcbfd5d 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
import java.util.UUID | |
import sttp.tapir._ | |
import sttp.tapir.json.circe._ | |
import io.circe.generic.auto._ | |
import sttp.model.StatusCode | |
case class AuthToken(token: String) | |
case class Error(msg: String, statusCode: StatusCode) extends Exception | |
val error: EndpointOutput[Error] = stringBody.and(statusCode).mapTo(Error) | |
val baseEndpoint: Endpoint[AuthToken, Error, Unit, Nothing] = endpoint | |
.in(header[String]("X-Authorization") | |
.description("Only authorized users can add pets") | |
.example("1234") | |
.mapTo(AuthToken)) | |
.in("api" / "1.0") | |
.errorOut(error) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment