api

package api

Members list

Packages

package api.endpoints

Type members

Classlikes

object ErrorHandler

Provides error handling for HTTP routes in a standardised way.

Provides error handling for HTTP routes in a standardised way.

The ErrorHandler wraps existing HTTP routes and ensures that:

  • NotFound errors return a 404 status with a JSON-encoded ErrorResponse.
  • Validation errors (e.g., IllegalArgumentException) return a 400 status.
  • Unexpected errors return a 500 status with a generic message.

This utility promotes consistent error handling across the application.

Attributes

Source
ErrorHandler.scala
Supertypes
class Object
trait Matchable
class Any
Self type
final case class ErrorResponse(error: String, message: String)

Represents a standard error response returned by the server in JSON format.

Represents a standard error response returned by the server in JSON format.

This case class is used to encapsulate error details, making it easy to serialise into a consistent JSON structure for HTTP error responses.

Value parameters

error

A string identifying the type of error (e.g., "NotFound", "BadRequest").

message

A descriptive message providing additional details about the error.

Attributes

Source
ErrorHandler.scala
Supertypes
trait Serializable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
class ServerBuilder(routes: HttpRoutes[IO])

A utility class for constructing and starting an HTTP server.

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
Supertypes
class Object
trait Matchable
class Any