# protocol > Register a custom protocol and intercept existing protocol requests. An example of implementing a protocol that has the same effect as the `file://` protocol: ```javascript const electron = require('electron'); const { app } = electron; const path = require('path'); app.on('ready', function() { const { protocol } = electron; protocol.registerFileProtocol('atom', function(request, callback) { const url = request.url.substr(7); callback({path: path.normalize(__dirname + '/' + url)}); }, function (error) { if (error) console.error('Failed to register protocol') }); }); ``` **Note:** This module can only be used after the `ready` event in the `app` module is emitted. ## Methods The `protocol` module has the following methods: ### `protocol.registerStandardSchemes(schemes)` * `schemes` Array - Custom schemes to be registered as standard schemes. A standard `scheme` adheres to what RFC 3986 calls [generic URI syntax](https://tools.ietf.org/html/rfc3986#section-3). This includes `file:` and `filesystem:`. ### `protocol.registerServiceWorkerSchemes(schemes)` * `schemes` Array - Custom schemes to be registered to handle service workers. ### `protocol.registerFileProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (optional) Registers a protocol of `scheme` that will send the file as a response. The `handler` will be called with `handler(request, callback)` when a `request` is going to be created with `scheme`. `completion` will be called with `completion(null)` when `scheme` is successfully registered or `completion(error)` when failed. * `request` Object * `url` String * `referrer` String * `method` String * `uploadData` Array (optional) * `callback` Function The `uploadData` is an array of `data` objects: * `data` Object * `bytes` Buffer - Content being sent. * `file` String - Path of file being uploaded. To handle the `request`, the `callback` should be called with either the file's path or an object that has a `path` property, e.g. `callback(filePath)` or `callback({path: filePath})`. When `callback` is called with nothing, a number, or an object that has an `error` property, the `request` will fail with the `error` number you specified. For the available error numbers you can use, please see the [net error list][net-error]. By default the `scheme` is treated like `http:`, which is parsed differently than protocols that follow the "generic URI syntax" like `file:`, so you probably want to call `protocol.registerStandardSchemes` to have your scheme treated as a standard scheme. ### `protocol.registerBufferProtocol(scheme, handler[, completion])` * `scheme` String * `handler` Function * `completion` Function (optional) Registers a protocol of `scheme` that will send a `Buffer` as a response. The usage is the same with `registerFileProtocol`, except that the `callback` should be called with either a `Buffer` object or an object that has the `data`, `mimeType`, and `charset` properties. Example: ```javascript protocol.registerBufferProtocol('atom', (request, callback) => { callback({mimeType: 'text/html', data: new Buffer('