App class
App class, almost the most important class.
Constructors
Properties
- debug → bool
-
Debug mode (TODO)
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- siteKey → String
-
ReCAPTCHA Site Key
final
- sslOptions → SSLOptions
-
SSL Options. for HTTPS
required if you set useHttps to true
final
- useHttps → bool
-
Enable HTTPS-only mode
Requires you to change sslOptions
final
Methods
-
apiKeyMiddleware(
ApiKeyManager apiKeyManager) → Middleware -
Middleware that validates API keys using the provided
apiKeyManager
. -
cacheResponse(
String key, dynamic value) → void - Stores a response in the cache under the given key.
-
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, calling all registered listeners.
-
errorHandlingMiddleware(
) → Middleware - Middleware that catches any unhandled errors in the stack and handles them according to the error handling strategy of the app.
-
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 response from the cache under the given key.
-
getFromConfig(
String key) → dynamic - Retrieves a configuration value by its key.
-
getGeoLocation(
String ip) → Future< String?> - Returns the country for the given IP address.
-
getVersion(
) → String - Returns the current version of dartcore as a string.
-
metadata(
) → Map< String, dynamic> - Returns the metadata associated with the application.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on(
String event, dynamic listener(dynamic)) → void - Adds a listener for a specific event.
-
openApi(
) → void - Adds SwaggerUI routes to the application.
-
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.
-
render(
HttpRequest request, CustomTemplateEngine ctemplateEngine, String template, Map< String, dynamic> context) → Future<void> - Renders a template file with the given context using a Custom Template Engine.
-
renderTemplate(
HttpRequest request, String templatePath, Map< String, dynamic> context) → Future<void> - Renders a template file with the given context.
-
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 a map of all the routes in the application, where each key is an HTTP method and the value is another map with the path as the key and the handler function as the value.
-
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 error handler. The handler is called with the original HttpRequest as an argument. The handler is responsible for writing a response to the client and closing the request.
-
set500(
dynamic handler(HttpRequest request, Object error)) → void - Sets a custom 500 error handler. The handler is called with the original HttpRequest and the error object as arguments. The handler is responsible for writing a response to the client and closing the request.
-
setRateLimiter(
RateLimiter ratelimiter) → void - Sets the rate limiter for the application.
-
setupApiKeyRoutes(
ApiKeyManager apiKeyManager) → void - Sets up the following routes for basic API key management:
-
shutdown(
) → Future< void> - Shuts down the server if it is running.
-
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 given CAPTCHA
response
with the providedsecretKey
. -
ws(
String path, void handler(WebSocket socket)) → void - Adds a WebSocket route to the application with the specified path. Associates the route with a handler function to manage WebSocket connections.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited