Skip to content

feature request: protocol api example #1364

Description

@SimonSiefke

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()
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions