Created
May 8, 2020 19:39
-
-
Save bkyrlach/7f938c6b4b5254a8f5c4eb9bdcfa0842 to your computer and use it in GitHub Desktop.
This file contains 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.concurrent.Executors | |
import cats.effect._ | |
import cats.implicits._ | |
import org.http4s.{HttpApp, HttpRoutes} | |
import org.http4s.syntax._ | |
import org.http4s.dsl.io._ | |
import org.http4s.implicits._ | |
import org.http4s.server.Router | |
import org.http4s.server.blaze._ | |
import org.http4s.server.staticcontent._ | |
import scala.concurrent.ExecutionContext.global | |
object Main extends IOApp { | |
val blockingPool = Executors.newFixedThreadPool(4) | |
val blocker = Blocker.liftExecutorService(blockingPool) | |
val httpApp: HttpApp[IO] = Router( | |
"/api" -> Api.apiRoutes, | |
"/" -> fileService[IO](FileService.Config("./content", blocker)) | |
).orNotFound | |
override def run(args: List[String]): IO[ExitCode] = | |
BlazeServerBuilder[IO] | |
.bindHttp(8080, "localhost") | |
.withHttpApp(httpApp) | |
.resource | |
.use(_ => IO.never) | |
.as(ExitCode.Success) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment