Serving the Application
Run a functional web server.
Ember Server
http4s runs your HttpApp[F] on a backend. The default modern choice is Ember, a pure-Scala server built on cats-effect and fs2, available as org.http4s.ember.server.EmberServerBuilder.
Older apps may use Blaze, but Ember is the recommended path going forward.
// build.sbt
// "org.http4s" %% "http4s-ember-server" % http4sVBuilding the Server
EmberServerBuilder.default[F] gives a builder you configure fluently: bind host and port, attach the app, then call .build to get a Resource[F, Server].
Using a Resource guarantees the socket is released on shutdown.
import com.comcast.ip4s._
import org.http4s.ember.server.EmberServerBuilder
EmberServerBuilder.default[IO]
.withHost(ipv4"0.0.0.0")
.withPort(port"8080")
.withHttpApp(app)
.buildAll lessons in this course
- Routes and HttpRoutes
- Requests and Responses
- JSON Endpoints
- Serving the Application