Chase class
The main Chase application class.
Chase is a lightweight, fast HTTP server framework for Dart inspired by Hono. It provides a simple and intuitive API for building web applications and APIs.
Example
final app = Chase();
app.get('/').handle((ctx) => ctx.res.text('Hello!'));
await app.start(port: 6060);
See also
- ChaseGroup, for organizing routes under a common prefix.
- ChaseBuilder, for configuring individual routes with middleware.
- Middleware, for creating request/response interceptors.
- Context, for accessing request and response objects in handlers.
- Available extensions
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- isRunning → bool
-
Whether the server is currently running.
no setter
- log → Logger
-
Application-level logger.
no setter
- logger ← Logger
-
Sets a custom logger for the application.
no getter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- server → HttpServer?
-
The underlying HTTP server instance.
no setter
Methods
-
all(
[Object path = '/']) → ChaseBuilderAll -
Creates a route builder that matches ALL HTTP methods.
inherited
-
delete(
[Object path = '/']) → ChaseBuilder -
Creates a DELETE route builder for the given path(s).
inherited
-
get(
[Object path = '/']) → ChaseBuilder -
Creates a GET route builder for the given path(s).
inherited
-
head(
[Object path = '/']) → ChaseBuilder -
Creates a HEAD route builder for the given path(s).
inherited
-
methodOverride(
{String? form = '_method', String? header, String? query}) → Chase - Enables HTTP method override for HTML forms.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notFound(
Handler handler) → Chase - Sets a custom handler for 404 Not Found responses.
-
on(
List< String> methods, [Object path = '/']) → ChaseBuilderOn -
Creates a route builder for specific HTTP methods.
inherited
-
onError(
ErrorHandler handler) → Chase - Sets a global error handler for uncaught exceptions.
-
onStart(
FutureOr< void> callback()) → Chase - Registers a callback to run when the server starts.
-
onStop(
FutureOr< void> callback()) → Chase - Registers a callback to run when the server stops.
-
options(
[Object path = '/']) → ChaseBuilder -
Creates an OPTIONS route builder for the given path(s).
inherited
-
patch(
[Object path = '/']) → ChaseBuilder -
Creates a PATCH route builder for the given path(s).
inherited
-
path(
String prefix) → ChaseGroup -
Creates a route group with the given path prefix.
inherited
-
plugin(
Plugin plugin) → Chase - Installs a plugin.
-
post(
[Object path = '/']) → ChaseBuilder -
Creates a POST route builder for the given path(s).
inherited
-
printRoutes(
) → void - Prints all registered routes to the console.
-
put(
[Object path = '/']) → ChaseBuilder -
Creates a PUT route builder for the given path(s).
inherited
-
route(
String method, [Object path = '/']) → ChaseBuilder -
Creates a route builder for any HTTP method with the given path(s).
inherited
-
routes(
String prefix, void define(ChaseGroup group)) → Chase -
Creates a route group and defines routes within a callback.
inherited
-
start(
{int port = 6060, Object? host, }) → Future< HttpServer> - Starts the HTTP server and begins listening for requests.
-
staticFiles(
String mountPath, String rootDirectory, [StaticOptions options = const StaticOptions()]) → Chase -
Available on Chase, provided by the ChaseConvenience extension
Serves static files from a directory. -
stop(
{bool force = false}) → Future< void> - Stops the HTTP server.
-
toString(
) → String -
A string representation of this object.
inherited
-
use(
Middleware middleware) → Chase -
Adds a middleware to this registrar.
inherited
-
useAll(
List< Middleware> middlewares) → Chase -
Adds multiple middlewares to this registrar.
inherited
-
withDefaults(
) → Chase -
Available on Chase, provided by the ChaseConvenience extension
Sets up commonly used middleware for development.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited