You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
package controllers
import javax.inject.{Inject, Singleton} import play.api.mvc._ import play.api.libs.json.Json import com.example.services.TaskLibraryService import util.IOHttp._ import com.typesafe.scalalogging.LazyLogging import cats.effect.IO import scala.concurrent.ExecutionContext import util.Schedulers
@Singleton class MonixHomeController @Inject() ( taskLibraryService: TaskLibraryService, cc: ControllerComponents )(schedulers: Schedulers, ec: ExecutionContext) extends AbstractController(cc) with LazyLogging {
private implicit val defaultScheduler = schedulers.dbScheduler
def authors(bookId: Long) = Action.asyncF { for { _ <- IO(logger.debug("Getting Authors")) authors <- taskLibraryService.getAuthorsForBook(bookId).to[IO] _ <- IO(logger.debug("Where am I now?")) _ <- IO.shift(ec) _ <- IO(logger.info("Got Authors")) res <- IO.pure(Ok(Json.toJson(authors))) } yield (res) }
}
|