add compatibility will old api

This commit is contained in:
Robo 2015-07-07 20:13:13 +05:30
parent da00329d78
commit 2cd5fb5694
5 changed files with 139 additions and 129 deletions

View file

@ -15,6 +15,9 @@ app.on('ready', function() {
protocol.registerProtocol('atom', function(request) {
var url = request.url.substr(7)
return new protocol.RequestFileJob(path.normalize(__dirname + '/' + url));
}, function (error, scheme) {
if (!error)
console.log(scheme, ' registered successfully')
});
});
```
@ -22,20 +25,22 @@ app.on('ready', function() {
**Note:** This module can only be used after the `ready` event
was emitted.
## protocol.registerProtocol(scheme, handler)
## protocol.registerProtocol(scheme, handler, callback)
* `scheme` String
* `handler` Function
* `callback` Function
Registers a custom protocol of `scheme`, the `handler` would be called with
`handler(error, request)` when the a request with registered `scheme` is made.
`handler(request)` when the a request with registered `scheme` is made.
You need to return a request job in the `handler` to specify which type of
response you would like to send.
## protocol.unregisterProtocol(scheme)
## protocol.unregisterProtocol(scheme, callback)
* `scheme` String
* `callback` Function
Unregisters the custom protocol of `scheme`.
@ -52,17 +57,19 @@ Unregisters the custom protocol of `scheme`.
`callback` returns a boolean whether the `scheme` can be handled already.
## protocol.interceptProtocol(scheme, handler)
## protocol.interceptProtocol(scheme, handler, callback)
* `scheme` String
* `handler` Function
* `callback` Function
Intercepts an existing protocol with `scheme`, returning `null` or `undefined`
in `handler` would use the original protocol handler to handle the request.
## protocol.uninterceptProtocol(scheme)
## protocol.uninterceptProtocol(scheme, callback)
* `scheme` String
* `callback` Function
Unintercepts a protocol.