Implement getEndpoints 2.x - #309
Closed
Amir-61 wants to merge 21 commits into
Closed
Conversation
- Add option to customize the XML rootElement tag
(default: "response")
- Add flag to disable declaration from response
(default: declaration is present)
- Bugfix changing behavior: `string` results from remote methods are
now quoted to avoid json2xmlparser throwing syntax error and returning
500 instead of a regular response body.
User can set the returned XML root element as follows:
"returns": {
"xml": { "wrapperElement": "Parent" }
}
User can disable XML declaration as follows:
"returns": {
"xml": { "declaration": false }
}
This is a back-port of the following GitHub pull request:
#272
Create `ContextBase` - a base class for all Context objects where we can put methods shared by all contexts. Move `remotes.getScope` to `ContextBase.prototype.getScope` as it belongs there more naturally and will make it easier to access scope in hooks that can access the `ctx` object only.
Deprecate `invokeMethodInContext(ctx, method, cb)` in favour of simpler `invokeMethodInContext(ctx, cb)`.
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)
Remote invocation phases
* 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)
Fix RemoteObjects.prototype.invokeMethodInContext to trigger afterError hooks only when there was an invocation error. This bug was introduced recently by #279.
Do not call "afterError" on success
"returns" arguments mapped to an http header should not be included in the response body.
Allow users to specify { type: 'file', root: true } for the single
argument that will be sent directly as the response body.
The following values are supported for file the file argument:
- String
- Buffer
- ReadableStream (anything that exposes .pipe() method)
…-2.x Add support for "file" return args [2.x] A back-port of #284
Handle array of errors.
Set to no compression when using change stream
* Implement getEndpoints * Deprecate getHttpMethod * Deprecate getFullPath
Member
Author
|
Closing since it needed to be based on |
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.
Connect to #305