408 Request Timeout
The server gave up waiting for the client to finish sending its request. Often caused by terrible network connections.
When and Why to Use It
Section titled “When and Why to Use It”Use this if the client opens a connection but takes an absurdly long time to actually send the data, to protect your server from being tied up forever.
Usage Examples
Section titled “Usage Examples”import { HttpException, get } from 'shokupan';
export const getResource = get('/resource', () => { throw new HttpException('Request Timeout', 408);});import { Controller, Get, HttpException } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') getResource() { throw new HttpException('Request Timeout', 408); }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(408).json({ error: 'Request Timeout' });});import { Controller, Get, HttpException } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') getResource() { throw new HttpException('Request Timeout', 408); }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 408; ctx.body = { error: 'Request Timeout' }; }});