426 Upgrade Required
You need to switch to a different, usually newer or more secure, protocol (like upgrading to TLS 1.3 or HTTP/2).
When and Why to Use It
Section titled “When and Why to Use It”Use this if you force clients to use WebSockets, or force them to upgrade from HTTP/1.1 to HTTP/2.
Usage Examples
Section titled “Usage Examples”import { HttpException, get } from 'shokupan';
export const getResource = get('/resource', () => { throw new HttpException('Upgrade Required', 426);});import { Controller, Get, HttpException } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') getResource() { throw new HttpException('Upgrade Required', 426); }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(426).json({ error: 'Upgrade Required' });});import { Controller, Get, HttpException } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') getResource() { throw new HttpException('Upgrade Required', 426); }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 426; ctx.body = { error: 'Upgrade Required' }; }});