Authorizer
controller that verifies the request's authorization credentials are correct, and a SecretController
that sends a response with secret information. By composing these two controllers together, we have a channel that verifies credentials before sending a secret. The benefit of controllers and channels is that controllers can be reused in multiple channels; the Authorizer
can protect other types of controllers without any change to its logic.401 Unauthorized
response protecting the endpoint controller from unauthorized requests. A "caching" controller could send a response with information from a cache, preventing the endpoint controller from performing an expensive query.Controller
(or a subclass). Middleware controllers are typically reusable, while endpoint controllers are typically not. If a middleware controller is not reusable, its logic might be better suited for the endpoint controller it precedes in the channel.Controller
). This class allows you to implement methods for each HTTP method (like GET or POST) for a given endpoint.name
key in pubspec.yaml
. In order for conduit serve
to run your application, there must be a .dart
file in lib/
with that same name. This is your application library file and it must declare a ApplicationChannel
subclass or import a file that does. This is the bare minimum requirement to run a Conduit application. (See Deploying for more details on running applications.)pubspec.yaml
and lib/application_name.dart
files are present alongside a few others:channel.dart
: A file solely for the ApplicationChannel
of an application. This file should be exported from application_name.dart
.controller/
: A directory for Controller
subclass files.model/
: A directory for ManagedObject<T>
subclass files.lib/
for organizing other types of files.dart:io
and relies on its HttpServer
implementation. When a Conduit application is started, one or more HttpServer
instances are bound to the port specified by conduit serve
. For each HTTP request, an instance of Request
is created to wrap the HttpRequest
from dart:io
. The Request
is added to a ApplicationChannel
, sending it through the channel of Controller
s until it is responded to.Request
from the application channel and manipulate the request with dart:io
only. Once removed, it is your responsibility to respond to the request by setting properties on and closing the HttpRequest.response
. To take a request out of the channel, simply return null
from a Controller
: