Skip to content

101 Switching Protocols

The server agrees to switch to a different protocol, like upgrading a standard HTTP connection to a continuous WebSocket connection.

Use this when a client asks to open a WebSocket connection. Your server responds with 101 to confirm ‘Yes, we are no longer speaking standard HTTP, we are now using WebSockets’.

import { HttpCode, get } from 'shokupan';
export const getResource = get('/resource', () => {
return { message: 'Switching Protocols' };
}).pipe(HttpCode(101));