421 Misdirected Request
The request was sent to a server that isn’t configured to produce a response for that specific destination.
When and Why to Use It
Section titled “When and Why to Use It”Used mostly by complex CDN/Server infrastructures when a request is accidentally routed to the wrong internal server.
Usage Examples
Section titled “Usage Examples”import { HttpException, get } from 'shokupan';
export const getResource = get('/resource', () => { throw new HttpException('Misdirected Request', 421);});import { Controller, Get, HttpException } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') getResource() { throw new HttpException('Misdirected Request', 421); }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(421).json({ error: 'Misdirected Request' });});import { Controller, Get, HttpException } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') getResource() { throw new HttpException('Misdirected Request', 421); }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 421; ctx.body = { error: 'Misdirected Request' }; }});