electron / electron/fiddle

feature request: protocol api example

Open
#1,364 0 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.