App class
App class, almost the most important class.
Properties
Methods
-
apiKeyMiddleware(
ApiKeyManager apiKeyManager) → Middleware - API Key Middleware
-
cacheResponse(
String key, dynamic value) → void - Caches a response
-
delete(
String path, Handler handler, {Map< String, dynamic> ? metadata}) → void - Adds a DELETE route to the application with the specified path. Associates the route with a handler function and optional metadata.
-
emit(
String event, [dynamic data]) → void - Emits an event
-
errorHandlingMiddleware(
) → Middleware - Middleware to handle errors
-
get(
String path, Handler handler, {Map< String, dynamic> ? metadata}) → void - Adds a GET route to the application with the specified path. Associates the route with a handler function and optional metadata.
-
getCachedResponse(
String key) → dynamic - Retrieves a cached response
-
getFromConfig(
String key) → dynamic - Get configuration
-
getGeoLocation(
String ip) → Future< String?> - Converts an IP to a Location
-
getVersion(
) → String - Returns dartcore's version
-
isBlockedCountry(
String ip) → Future< bool> - Checks if a country is blocked
-
metadata(
) → Map< String, dynamic> - Returns all the metadata e.g. final metadata = app.metadata();
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
String event, dynamic listener(dynamic)) → void - Adds an event listener
-
openApi(
) → void -
Makes SwaggerUI routes (can be copy-pasted and edited but just add
app.
before eachroute()
) -
params(
HttpRequest request) → Map< String, String> - Retrieves query parameters from the given HTTP request.
-
parseJson(
HttpRequest request) → Future< Map< String, dynamic> > - Parses the request body as JSON and returns it as a Map<String, dynamic>
-
parseMultipartRequest(
HttpRequest request, String saveTo) → Future< void> - Parses a multipart/form-data request and saves the uploaded files
-
post(
String path, Handler handler, {Map< String, dynamic> ? metadata}) → void - Adds a POST route to the application with the specified path. Associates the route with a handler function and optional metadata.
-
put(
String path, Handler handler, {Map< String, dynamic> ? metadata}) → void - Adds a PUT route to the application with the specified path. Associates the route with a handler function and optional metadata.
-
renderTemplate(
HttpRequest request, String templatePath, Map< String, dynamic> context) → Future<void> - Renders a template and sends it as a response
-
route(
String method, String path, Handler handler, {Map< String, dynamic> ? metadata}) → void - Adds a route to the application with the specified HTTP method and path. Associates the route with a handler function and optional metadata.
-
routes(
) → Map< String, Map< String, Handler> > - Returns the routes e.g. final routes = app.routes();
-
serveStaticFile(
HttpRequest request, String filePath) → Future< void> -
Serves a static file at
filePath
to the client. -
set404(
dynamic handler(HttpRequest request)) → void - Sets a custom 404 Message
-
set500(
dynamic handler(HttpRequest request, Object error)) → void - Sets a custom 500 Message
-
setRateLimiter(
RateLimiter ratelimiter) → void - Sets a custom rate limiter
-
setupApiKeyRoutes(
ApiKeyManager apiKeyManager) → void - Sets up the following routes for basic API key management:
-
shutdown(
) → Future< void> - Gracefully shuts down the server
-
start(
{String address = '0.0.0.0', int port = 8080}) → Future< void> - Starts the server.
-
toString(
) → String -
A string representation of this object.
inherited
-
use(
Middleware middleware) → void - Adds a middleware to the list of middlewares that will be executed in order. Note that the order of execution is the same as the order of addition. You can add a middleware at any time, but it will only start executing on new requests. If you add a middleware after the server is started, it will be executed on new requests, but not on requests that are already in progress.
-
verifyCaptcha(
String response, String secretKey) → Future< bool> - Verifies the CAPTCHA response
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited