Remote invocation phases - #279
Merged
Merged
Conversation
Deprecate `invokeMethodInContext(ctx, method, cb)` in favour of simpler `invokeMethodInContext(ctx, cb)`.
Member
Author
|
@slnode test please |
Rework "invokeMethodInContext" to use a concept of phases that allows external components a more fine-grained way for extending built-in functionality. The new API is exposed on `remotes.phases`, which is an instance of PhaseList from loopback-phase. There are two built-in phases available: "auth" and "invoke". Hooks registered via `remotes.authorization`, `remotes.before` and `remotes.after` are invoked in "auth", "invoke:before" and "invoke:after" phases. Here is the complete order in which different hooks/handler are called: - hook "authorization" - phase handlers "auth" - hook "remotes.before" - phase handlers "invoke:before" - invoke method - phase handlers "invoke:use" - hook "remotes.after" - phase handlers "invoke:after"
Implement a method for registering phase handlers with a method-name
based filter.
Example usage:
// match static methods
remotes.registerPhaseHandler('invoke', 'User.*', fn)
// match prototype methods
remotes.registerPhaseHandler('invoke', 'User.prototype.*', fn)
// match all model methods
remotes.registerPhaseHandler('invoke', 'User.**', fn)
bajtos
force-pushed
the
feature/phases
branch
from
February 1, 2016 17:02
deb7906 to
89690db
Compare
Member
👍 |
Member
|
LGTM |
Member
Author
|
Backported to 2.x via 0ab0647. |
bajtos
added a commit
that referenced
this pull request
Feb 2, 2016
* Backport pull request #279 from strongloop/feature/phases (Miroslav Bajtoš) * Add remotes.registerPhaseHandler (Miroslav Bajtoš) * Add remote invocation phases (Miroslav Bajtoš) * Simplify invokeMethodInContext (Miroslav Bajtoš) * Extract ContextBase and ctx.getScope() (Miroslav Bajtoš) * Customize XML root element in remoteMethod (David Cheung)
bajtos
added a commit
that referenced
this pull request
Feb 6, 2016
Fix RemoteObjects.prototype.invokeMethodInContext to trigger afterError hooks only when there was an invocation error. This bug was introduced recently by #279.
bajtos
added a commit
that referenced
this pull request
Feb 6, 2016
Fix RemoteObjects.prototype.invokeMethodInContext to trigger afterError hooks only when there was an invocation error. This bug was introduced recently by #279.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
0) Simplify invokeMethodInContext
Deprecate
invokeMethodInContext(ctx, method, cb)in favour of simplerinvokeMethodInContext(ctx, cb).1) Add remote invocation phases
Rework "invokeMethodInContext" to use a concept of phases that allows
external components a more fine-grained way for extending built-in
functionality.
The new API is exposed on
remotes.phases, which is an instanceof PhaseList from loopback-phase.
There are two built-in phases available: "auth" and "invoke".
Hooks registered via
remotes.authorization,remotes.beforeandremotes.afterare invoked in "auth", "invoke:before" and"invoke:after" phases.
Here is the complete order in which different hooks/handler are called:
2) Add
remotes.registerPhaseHandlerImplement a method for registering phase handlers with a method-name
based filter.
Example usage:
Connect to strongloop-internal/scrum-loopback#729
/to @raymondfeng @ritch please review
/cc @chayab