orbiter library

High-throughput, low-allocation HTTP backend framework for Dart.

Classes

BackendServer
High-performance HTTP server built directly on the HttpServer of the dart:io runtime.
ConcurrencyLimit
Admission control for a server: how many requests run at once, how many may wait for a slot, and for how long.
HttpDispatcher
HTTP dispatch engine that connects low-level requests from HttpServer (dart:io) to the framework's functional pipeline.
Interceptor
Interface for class-based interceptors.
MultiWorkerServer
HTTP server that runs one BackendServer per isolate on the same TCP port.
PathParameters
Immutable container for the dynamic route parameters captured by the Router.
Pipeline
Functional chaining builder for middlewares and interceptors.
Request
Represents an incoming HTTP request in orbiter.
RequestContext
A lightweight, high-performance heterogeneous context container.
Response
Represents an HTTP response produced by the application or framework.
Router
High-performance HTTP router based on a Radix/Trie tree.
WorkerApp
What one worker serves, built by a WorkerSetup inside the worker's isolate.
WorkerContext
Identity of a worker, passed to its WorkerSetup.

Extensions

RequestPathParamsExtension on Request
Ergonomic extension on Request for direct access to the route parameters.

Constants

defaultMaxBodySize → const int
Default request body limit: 1 MiB.

Functions

cors({List<String> origins = const ['*'], List<String> methods = const ['GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'OPTIONS', 'HEAD'], List<String> headers = const ['Origin', 'Content-Type', 'Accept', 'Authorization', 'X-Requested-With'], List<String>? exposeHeaders, bool allowCredentials = false, int? maxAge = 86400}) → InterceptorFunction
Creates a CORS (Cross-Origin Resource Sharing) middleware.
requestLogger({LogWriter? logFn}) → InterceptorFunction
Creates a telemetry and logging middleware for HTTP requests.
securityHeaders({String contentTypeOptions = 'nosniff', String frameOptions = 'DENY', String xssProtection = '0', String? strictTransportSecurity, String referrerPolicy = 'no-referrer'}) → InterceptorFunction
Creates a middleware that injects recommended HTTP security headers into the application's responses.

Typedefs

ErrorHandler = FutureOr<Response> Function(Object error, StackTrace stackTrace, Request request)
Signature of the global error handler (Error Boundary).
ErrorReporter = void Function(Object error, StackTrace stackTrace, Request? request)
Signature of the error reporter: receives every unhandled failure from the handler and every failure while writing the response. request is null only if the failure occurs before the Request exists.
ExemptPredicate = bool Function(Request request)
Decides whether a request bypasses a ConcurrencyLimit.
Handler = FutureOr<Response> Function(Request request)
A function that handles an incoming Request and produces a Response.
InterceptorFunction = FutureOr<Response> Function(Request request, NextFunction next)
A middleware/interceptor function in the request processing pipeline.
LogWriter = void Function(String message)
Signature of the logging callback.
NextFunction = FutureOr<Response> Function(Request request)
Callback passed to an Interceptor to delegate to the next handler/interceptor.
RejectResponseBuilder = FutureOr<Response> Function(Request request, int retryAfterSeconds)
Builds the response for a request refused by a ConcurrencyLimit.
WorkerSetup = FutureOr<WorkerApp> Function(WorkerContext context)
Builds one worker's application. It runs inside the worker's isolate, so whatever it creates (pool, repositories, router) belongs to that worker alone.

Exceptions / Errors

MultiWorkerStartException
Thrown by MultiWorkerServer.start when a worker cannot start.
PayloadTooLargeException
Thrown when the request body exceeds the configured limit (maxBodySize). The default Error Boundary converts it into 413 Payload Too Large.
WorkerExitedException
Reported to MultiWorkerServer.start's onError when a worker stops without finishing a requested shutdown: while serving, or while draining in MultiWorkerServer.close. The worker is not restarted.