feature request: protocol api example
- Dominant language
- TypeScript
- Stars
- 7.8k
- Forks
- 762
- Avg merge
- 15h 27m
- Merged PRs (30d)
- 12
Description
Electron fiddle already has lots of great examples for using different electron apis. I'm thinking a [protocol api](https://www.electronjs.org/docs/latest/api/protocol) example could be a useful addition to the Electron fiddle examples.
Based on the electron documentation, this is how the example could look like:
```js
const { app, BrowserWindow, protocol } = require('electron')
function createWindow () {
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {}
})
mainWindow.loadURL('some-protocol://index.html')
}
app.whenReady().then(() => {
protocol.handle('some-protocol', () => {
return new Response(
Buffer.from('
Hello from protocol handler
'), // Could also be a string or ReadableStream.{ headers: { 'content-type': 'text/html' } }
);
});
createWindow()
})
```
Contributor guide
Assessment
This issue has not been assessed yet.