@WrRan
2016-11-09T17:05:11.000000Z
字数 2030
阅读 818
sails
Stability: 2 - Stable
In order for this hook to load, the following other hooks must have already finished loading:
If the following other core hooks are enabled, the behavior of this hook will change:
If this hook is disabled, in order for Sails to load, the following other core hooks must also be disabled:
This hook's responsibilities are:
This hook starts an http or https server and listens for incoming requests when Sails core
emits an event letting us know it's time to "lift" (rather than just "load").
This hook binds built-in HTTP middleware, in addition to custom middleware functions (sails.config.http.middleware
).
The order in which middleware can be bound is configurable in sails.config.http.middleware.order
.
Note that it is possible for the configured HTTP middleware stack to be shared with the
core router built into Sails-- this would make the same stack take effect for all virtual requests
including sockets. Currently, an abbreviated version of this stack is built-in tolib/router/
in an imperative way (rather than the declarative approach used here: a sorted array of named middleware).In Sails core, this has been explored in a number of different ways in the past.
In the future, it would be possible to add a separate middleware stack configuration for virtual
requests (including socket requests). However, while this would certainly be more consistent, in practice,
this would have an unwanted impact on performance.
This hook sets the following implicit default configuration on sails.config
:
TODO: document
(if you'd like to help, please send a pull request expanding this section. See
hooks/logger/README.md
for an example)
hook:http:loaded
Emitted when this hook has been automatically loaded by Sails core, and triggered the callback in its initialize
function.
TODO: document
(if you'd like to help, please send a pull request expanding this section. See
hooks/responses/README.md
for an example)
If you have a question about this hook that isn't covered here, please feel free to send a PR adding it to this section (even if you don't have the answer, a core maintainer will merge your PR and add an answer as soon as possible)