Angel class
A powerful real-time/REST/MVC server class.
- Inheritance
-
- Object
- Router<
RequestHandler> - Routable
- Angel
Constructors
-
Angel({Reflector reflector = const ThrowingReflector(errorMessage: _reflectionErrorMessage), AngelEnvironment environment = angelEnv, Logger? logger, bool allowMethodOverrides = true, FutureOr<
String> serializer(dynamic)?, ViewGenerator? viewGenerator})
Properties
- allowMethodOverrides ↔ bool
-
Determines whether to allow HTTP request method overrides.
getter/setter pair
-
children
→ List<
Angel> -
All child application mounted on this instance.
no setter
- configuration → Map
-
A Map of application-specific data that can be accessed.
finalinherited
- container → Container
-
A
Container
used to inject dependencies.no setterinherited -
controllers
→ Map<
Pattern, Controller> -
A set of Controller objects that have been loaded into the application.
no setter
-
encoders
→ Map<
String, Converter< List< >int> , List<int> > -
A global Map of converters that can transform responses bodies.
final
- environment → AngelEnvironment
-
The AngelEnvironment in which the application is running.
final
- errorHandler ↔ AngelErrorHandler
-
The handler currently configured to run on AngelHttpExceptions.
getter/setter pair
-
handlerCache
→ Map<
String, Tuple4< List, Map< >String, dynamic> , ParseResult<RouteResult> , MiddlewarePipeline> -
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- logger ↔ Logger
-
Assign a custom logger.
Passing null will reset to default logger
getter/setter pair
-
middleware
→ List<
RequestHandler> -
no setterinherited
- mimeTypeResolver → MimeTypeResolver
-
A
MimeTypeResolver
that can be used to specify the MIME types of files not known bypackage:mime
.final -
mounted
→ Map<
Pattern, Router< RequestHandler> > -
no setterinherited
-
onService
→ Stream<
Service> -
Fired whenever a service is added to this instance.
no setterinherited
-
optimizedRouter
→ Router<
RequestHandler> -
Returns the flattened version of this router in production.
no setter
- parent → Angel?
-
Returns the parent instance of this application, if any.
no setter
-
preContained
→ Map<
dynamic, InjectionRequest> -
A Map of dependency data obtained via reflection.
no setter
-
responseFinalizers
→ List<
RequestHandler> -
Always run before responses are sent.
final
-
routes
→ List<
Route< RequestHandler> > -
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
serializer
↔ FutureOr<
String> Function(dynamic)? -
A middleware to inject a serialize on every request.
getter/setter pair
-
services
→ Map<
Pattern, Service> -
A set of Service objects that have been mapped into routes.
no setterinherited
-
shutdownHooks
→ List<
AngelConfigurer> -
Plug-ins to be called right before server shutdown.
final
-
startupHooks
→ List<
AngelConfigurer> -
Plug-ins to be called right before server startup.
final
- viewGenerator ↔ ViewGenerator?
-
A function that renders views.
getter/setter pair
Methods
-
addRoute(
String method, String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to the given path
for requests with the given method (case-insensitive).
Provide '*' as the method to respond to all methods.
override
-
all(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to any request matching the given path.
inherited
-
bootstrapContainer(
) → void - Loads some base dependencies into the service container.
-
chain(
Iterable< RequestHandler> middleware) → ChainedRouter<RequestHandler> -
Prepends the given
middleware
to any routes created by the resulting router.inherited -
clone(
) → Router< RequestHandler> -
Returns a Router with a duplicated version of this tree.
inherited
-
close(
) → Future< void> -
Shuts down the server, and closes any open StreamControllers.
override
-
configure(
AngelConfigurer configurer) → Future - Applies an AngelConfigurer to this instance.
-
delete(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a DELETE request.
inherited
-
dumpTree(
{dynamic callback(String tree)?, String header = 'Dumping route tree:', String tab = ' ', bool showMatchers = false}) → void -
Creates a visual representation of the route hierarchy and
passes it to a callback. If none is provided,
print
is called.override -
enableCache(
) → void -
Enables the use of a cache to eliminate the overhead of consecutive resolutions of the same path.
inherited
-
executeHandler(
dynamic handler, RequestContext req, ResponseContext res) → Future< bool> -
Runs some
handler
. Returnstrue
if request execution should continue. -
fallback(
RequestHandler handler) → Route< RequestHandler?> -
Shorthand for calling
all('*', handler)
. -
findHookedService<
T extends Service> (Pattern path) → HookedService< dynamic, dynamic, T> ? -
Shorthand for finding a HookedService in a statically-typed manner.
inherited
-
findProperty(
dynamic key) → dynamic - Attempts to find a property by the given name within this application.
-
findService<
T extends Service> (Pattern path) → T? -
Retrieves the service assigned to the given path.
inherited
-
findServiceOf<
Id, Data> (Pattern path) → Service< Id, Data> ? -
Shorthand for finding a Service in a statically-typed manner.
inherited
-
get(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a GET request.
inherited
-
getHandlerResult(
dynamic handler, RequestContext req, ResponseContext res) → Future -
group(
String path, void callback(Router< RequestHandler> router), {Iterable<RequestHandler> middleware = const [], String name = ''}) → SymlinkRoute<RequestHandler> -
Creates a route, and allows you to add child routes to it
via a Router instance.
inherited
-
groupAsync(
String path, FutureOr< void> callback(Router<RequestHandler> router), {Iterable<RequestHandler> middleware = const [], String name = ''}) → Future<SymlinkRoute< RequestHandler> > -
Asynchronous equivalent of group.
inherited
-
head(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a HEAD request.
inherited
-
mount(
String path, Router< RequestHandler> router) → SymlinkRoute<RequestHandler> -
Incorporates another Router's routes into this one's.
override
-
mountController<
T extends Controller> ([Type? type]) → Future< T> - Shorthand for using the container to instantiate, and then mount a Controller. Returns the created controller.
-
Generates a URI string based on the given input.
Handy when you have named routes.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
optimizeForProduction(
{bool force = false}) → void -
Runs several optimizations, if
angelEnv.isProduction
istrue
. -
options(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const {}}) → Route<RequestHandler> -
Adds a route that responds to a OPTIONS request.
inherited
-
patch(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a PATCH request.
inherited
-
post(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route<RequestHandler> -
Adds a route that responds to a POST request.
inherited
-
put(
String path, RequestHandler handler, {Iterable< RequestHandler> middleware = const []}) → Route -
Adds a route that responds to a PUT request.
inherited
-
resolve(
String absolute, String relative, List< RoutingResult< out, {String method = 'GET', bool strip = true}) → boolRequestHandler?> > -
Finds the first Route that matches the given path,
with the given method.
inherited
-
resolveAbsolute(
String path, {String method = 'GET', bool strip = true}) → Iterable< RoutingResult< RequestHandler> > -
Returns the result of resolve with
path
passed as bothabsolute
andrelative
.inherited -
resolveAll(
String absolute, String relative, {String method = 'GET', bool strip = true}) → Iterable< RoutingResult< RequestHandler> > -
Finds every possible Route that matches the given path,
with the given method.
inherited
-
runContained(
Function handler, RequestContext req, ResponseContext res, [Container? container]) → Future - Run a function after injecting from service container. If this function has been reflected before, then the execution will be faster, as the injection requirements were stored beforehand.
-
runReflected(
Function handler, RequestContext req, ResponseContext res, [Container? container]) → Future - Runs with DI, and always reflects. Prefer runContained.
-
toString(
) → String -
A string representation of this object.
inherited
-
use<
Id, Data, T extends Service< (Id, Data> >String path, T service) → HookedService< Id, Data, T> -
Mounts a
service
at the givenpath
.override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited