ServerBuilder

api.ServerBuilder
class ServerBuilder(routes: HttpRoutes[IO])

A utility class for constructing and starting an HTTP server.

This class uses the EmberServerBuilder to set up a server with the provided HTTP routes. It integrates error handling for routes and ensures the server is properly managed as a Resource, allowing safe startup and shutdown.

Value parameters

routes

The HTTP routes to be served by the server.

Attributes

Source
ServerBuilder.scala
Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def startServer(host: Host, port: Port): Resource[IO, Server]

Configures and starts an HTTP server with the specified host and port.

Configures and starts an HTTP server with the specified host and port.

This method uses the EmberServerBuilder to create and manage the server. It wraps the provided routes with the ErrorHandler to ensure consistent error handling, and builds an HTTP application that listens on the specified host and port.

Value parameters

host

The host address on which the server will listen (e.g., Host.fromString("127.0.0.1")).

port

The port number on which the server will listen (e.g., Port.fromInt(8080)).

Attributes

Returns

A Resource[IO, Server] that represents the running HTTP server. The server is automatically cleaned up when the Resource is released.

Source
ServerBuilder.scala