netto library

Netto

Classes

Builder
Base builder abstraction that wires routes into the shared radix tree.
Ctx
Request context shared between middleware and handlers.
CtxRequest
Wrapper around HttpRequest offering convenient access to request data and the shared contextual extras map.
CtxResponse
Response helper that tracks outgoing data and exposes the shared extras map used by middleware and handlers.
FormData
Aggregated multipart form result.
Group
Route builder that scopes nested routes under a shared prefix and middleware.
LoggerConfig
Configuration object for the structured logging middleware.
LoggerEvent
Immutable snapshot of request/response metadata passed to formatting hooks.
MultipartLimits
Limits for multipart processing. All fields are optional.
Netto
Primary entry-point combining router, middleware, and server integration.
RadixNode<T>
Node used by the radix tree to store path segments and route metadata.
RadixResult<T>
Result returned when resolving a path through the radix tree.
RadixTree<T>
Lightweight radix tree optimized for HTTP route lookup.
RouteNode
Holds the handler and middleware context for a concrete route.
Router
HTTP router based on a radix tree with middleware support.
UploadedFile
A streamed uploaded file backed by a temporary file on disk.

Extension Types

FormDataFields
Wrapper around Map<String, List<String>> representing form fields, such as those parsed from application/x-www-form-urlencoded or multipart/form-data requests.

Extensions

MiddlewareExtensions on Middleware
Extensions on Middleware to aid in composing Middleware and Handlers.

Functions

catchTopLevelErrors(void callback(), void onError(dynamic error, StackTrace)) → void
Runs callback while ensuring asynchronous errors are reported via onError.
handleRequest(HttpRequest request, Handler handler) Future<void>
Wraps an incoming request with Ctx and executes the application handler.
logger() Middleware
Returns middleware that logs request and response information.
loggerWithConfig(LoggerConfig config) Middleware
Returns middleware that logs request and response information using config.
serve(Handler handler, Object address, int port, {SecurityContext? securityContext, int backlog = 0, bool shared = false, bool suppressBanner = false}) Future<HttpServer>
Starts an HttpServer wired to the provided handler.
serveRequests(Stream<HttpRequest> requests, Handler handler) → void
Consumes the stream of requests and forwards each to handler.

Typedefs

CustomTagCallback = String? Function(LoggerEvent event)
Produces a custom tag value for the serialized log output.
ErrorHandler = FutureOr<void> Function(Ctx ctx, HttpException error)
Signature for error handlers triggered by uncaught HttpExceptions.
Handler = FutureOr<void> Function(Ctx ctx)
Signature for route handlers.
LogSkipper = bool Function(Ctx ctx)
Callback that decides whether logging should be skipped for the request.
Middleware = FutureOr<Handler> Function(Handler next)
Signature for middleware that transforms a downstream Handler.

Exceptions / Errors

HijackException
Internal sentinel exception thrown once a request has been hijacked.
HttpException
Minimal HTTP exception hierarchy with common helpers.
HttpExceptionBadRequest
400 Bad Request.
HttpExceptionConflict
409 Conflict.
HttpExceptionForbidden
403 Forbidden.
HttpExceptionInternalServerError
500 Internal Server Error.
HttpExceptionMethodNotAllowed
405 Method Not Allowed.
HttpExceptionNotFound
404 Not Found.
HttpExceptionPayloadTooLarge
413 Payload Too Large.
HttpExceptionUnauthorized
401 Unauthorized.
HttpExceptionUnprocessableEntity
422 Unprocessable Entity.
HttpExceptionUnsupportedMediaType
415 Unsupported Media Type.
HttpExceptionWithStatus
A generic HttpException for an arbitrary status code.