RelicApp class final

The main application class for a Relic web server.

RelicApp extends RelicRouter and provides a convenient way to create, configure, and run a Relic HTTP server.

Hot Reload Support

When running with --enable-vm-service, RelicApp automatically listens for hot-reload requests. When a hot reload is triggered, it will re-configure the internal router with the latest route definitions.

This allows you to modify your route handlers and see the changes immediately without restarting the server. Note that this only works for changes to the route configuration and handlers - changes to server state or global variables may require a full restart.

Implemented types
Available extensions

Constructors

RelicApp()

Properties

asHandler Handler

Available on RelicRouter, provided by the RouterHandlerEx extension

Makes RelicRouter callable as a Handler.
no setter
delegate Router<Handler>
getter/setter pair
fallback Handler?
The fallback value returned when no route matches the request path.
getter/setter pairoverride
hashCode int
The hash code for this object.
no setterinherited
isEmpty bool
Returns true if the router has no routes.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(Method method, String path, Handler route) → void
Adds a route definition to the router.
override
attach(String path, RelicRouter subRouter) → void
Attaches a sub-router to this router at the specified path.
override
call(Request req) FutureOr<Result>

Available on RelicRouter, provided by the RouterHandlerEx extension

Similar to HandlerObject this extension allows a Router to be callable like a Handler.
close() Future<void>
inject(RouterInjectable injectable) → void
Injects an injectable into the router. Unlike add it allows the injectable object to determine how to be mounted on the router.
override
lookup(Method method, String path) LookupResult<Handler>
Looks up a route matching the provided path.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(FutureOr<Adapter> adapterFactory(), {int noOfIsolates = 1}) Future<RelicServer>
Creates and starts a RelicServer with the configured routes.
serve({InternetAddress? address, int port = 8080, SecurityContext? securityContext, int backlog = 0, bool v6Only = false, bool shared = false, int noOfIsolates = 1}) Future<RelicServer>

Available on RelicApp, provided by the RelicAppIOServeEx extension

Starts a HttpServer that listens on the specified address and port and sends requests to handler.
toString() String
A string representation of this object.
inherited
use(String path, Middleware map) → void
Adds a middleware function to the router.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited