dart_frog library

A fast, minimalistic backend framework for Dart 🎯

Classes

Cascade
A class that supports calling multiple handlers in sequence and returns the first acceptable response.
FormData
The fields and files of received form data request.
Pipeline
A helper that makes it easy to compose a set of Middleware and a Handler.
Request
An HTTP request.
RequestContext
An object representing a request-specific context.
Response
An HTTP response.
Router
A class that routes requests to handlers based on HTTP verb and route pattern.
UploadedFile
The uploaded file of a form data request.

Enums

HttpMethod
HTTP Method such as GET or PUT.

Extensions

HandlerUse on Handler
Extension on Handler which adds support for applying middleware to the request pipeline.

Functions

createStaticFileHandler({String path = 'public'}) Handler
Creates a Handler that serves static files within provided path. Defaults to the public directory.
fromShelfHandler(Handler handler) Handler
Convert from a shelf.Handler into a Handler.
fromShelfMiddleware(Middleware middleware) Middleware
Convert from shelf.Middleware into Middleware.
hotReload(FutureOr<HttpServer> initializer()) → void
Hot reload support for the server returned by the initializer.
provider<T extends Object?>(T create(RequestContext context)) Middleware
Provide a value to the current handler by calling create lazily.
requestLogger({void logger(String message, bool isError)?}) Middleware
Middleware which prints the time of the request, the elapsed time for the inner handlers, the response's status code and the request URI.
serve(Handler handler, Object address, int port, {String? poweredByHeader = 'Dart with package:dart_frog', SecurityContext? securityContext, bool shared = false}) Future<HttpServer>
Starts an HttpServer that listens on the specified address and port and sends requests to handler.

Typedefs

Handler = FutureOr<Response> Function(RequestContext context)
A function which handles a request via the provided context.
Middleware = Handler Function(Handler handler)
A function which creates a new Handler by wrapping a Handler.