Authorizercontroller that verifies the request's authorization credentials are correct, and a
SecretControllerthat 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
Authorizercan protect other types of controllers without any change to its logic.
401 Unauthorizedresponse 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.
pubspec.yaml. In order for
conduit serveto run your application, there must be a
lib/with that same name. This is your application library file and it must declare a
ApplicationChannelsubclass 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.)
lib/application_name.dartfiles are present alongside a few others:
channel.dart: A file solely for the
ApplicationChannelof an application. This file should be exported from
controller/: A directory for
model/: A directory for
lib/for organizing other types of files.
dart:ioand relies on its
HttpServerimplementation. When a Conduit application is started, one or more
HttpServerinstances are bound to the port specified by
conduit serve. For each HTTP request, an instance of
Requestis created to wrap the
Requestis added to a
ApplicationChannel, sending it through the channel of
Controllers until it is responded to.
Requestfrom the application channel and manipulate the request with
dart:ioonly. 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