Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: protocol api example #1364

Open
SimonSiefke opened this issue Jun 1, 2023 · 0 comments · May be fixed by #1365
Open

feature request: protocol api example #1364

SimonSiefke opened this issue Jun 1, 2023 · 0 comments · May be fixed by #1365

Comments

@SimonSiefke
Copy link

Electron fiddle already has lots of great examples for using different electron apis. I'm thinking a protocol api example could be a useful addition to the Electron fiddle examples.

Based on the electron documentation, this is how the example could look like:

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('<h1>Hello from protocol handler</h1>'), // Could also be a string or ReadableStream.
      { headers: { 'content-type': 'text/html' } }
    );
  });

  createWindow()
})
@SimonSiefke SimonSiefke linked a pull request Jun 1, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant