-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tapiro can't return non-200 status codes, except for 4xx #183
Comments
This can be done using
Here you have an example: object ControllerEndpoints {
def create[AuthToken](
statusCodes: String => StatusCode = _ => StatusCode.UnprocessableEntity
)(
implicit codec0: JsonCodec[SpittyCash],
codec1: JsonCodec[Errore.Errorone],
codec2: JsonCodec[Errore.Errorino],
codec3: PlainCodec[String]
) = new ControllerEndpoints[AuthToken] {
override val ghetto: Endpoint[String, Errore, SpittyCash, Nothing] =
endpoint.get
.in("ghetto")
.in(query[String]("at"))
.errorOut(
oneOf[Errore](
statusMapping(statusCodes("Errorone"), jsonBody[Errore.Errorone]),
statusMapping(statusCodes("Errorino"), jsonBody[Errore.Errorino])
)
)
.out(jsonBody[SpittyCash])
}
} Improving the way this is done is part of #68 |
This means I have to create error types like retro/metarpheus/core/src/test/scala/io.buildo.metarpheus/core/extractors/ModelSuite.scala Lines 144 to 174 in 505e639
|
Correct, in the previous example the controller would be sealed trait Errore
object Errore {
case class Errorone(message: String) extends Errore
case class Errorino(message: String) extends Errore
}
trait Controller[F[_], AuthToken] {
@query
def ghetto(at: String): F[Either[Errore, ...]]
}
|
tapiro should at least provide the possibility of returning 5xx status codes
/cc @calippo
The text was updated successfully, but these errors were encountered: