All Downloads are FREE. Search and download functionalities are using the official Maven repository.

sttp.tapir.server.interceptor.RequestHandler.scala Maven / Gradle / Ivy

The newest version!
package sttp.tapir.server.interceptor

import sttp.monad.MonadError
import sttp.tapir.model.ServerRequest
import sttp.tapir.server.ServerEndpoint

trait RequestHandler[F[_], R, B] {
  def apply(request: ServerRequest, endpoints: List[ServerEndpoint[R, F]])(implicit monad: MonadError[F]): F[RequestResult[B]]
}

object RequestHandler {
  def from[F[_], R, B](f: (ServerRequest, List[ServerEndpoint[R, F]], MonadError[F]) => F[RequestResult[B]]): RequestHandler[F, R, B] =
    new RequestHandler[F, R, B] {
      override def apply(request: ServerRequest, endpoints: List[ServerEndpoint[R, F]])(implicit
          monad: MonadError[F]
      ): F[RequestResult[B]] = f(request, endpoints, monad)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy