Open
Description
Describe the problem
One can easy implement GET, PUT in an api route by a function (see below)
import { json } from '@sveltejs/kit';
export function GET() {
const number = Math.floor(Math.random() * 6) + 1;
return json(number);
}
Describe the proposed solution
If we implement UPGRADE Protocol_upgrade_mechanism we could implement websockets aswell
this file is in src/route/chat-app/server.js
connect with new WebSocket('/chap-app')
// if this file is in src/route/chat-app/server.js
import { json } from '@sveltejs/kit';
// called when http call wants to upgrade to websocket protocol
export function UPGRADE() {
// this function will be called after successfull upgrade
return function connection(ws: WebSocket) {
ws.send('hello');
ws.onmessage = (event) => {..});
// other handlers
}
}
### Alternatives considered
_No response_
### Importance
would make my life easier
### Additional Information
Currently, customers expect some kind of live real time interaction, a clean solution integrating with sveltekit would be a huge advantage