Skip to content

Instantly share code, notes, and snippets.

@adamw
Last active May 18, 2020 08:28
Show Gist options
  • Save adamw/a58a25a074c49b6776fb19319bcbfd5d to your computer and use it in GitHub Desktop.
Save adamw/a58a25a074c49b6776fb19319bcbfd5d to your computer and use it in GitHub Desktop.
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