308 Permanent Redirect
Like 301, but strictly forces the client to use the exact same HTTP method when following the permanent redirect.
When and Why to Use It
Section titled “When and Why to Use It”Use this instead of 301 when you want a permanent redirect, but explicitly require the client to use the exact same HTTP method (like keeping a POST as a POST) on the new URL.
Usage Examples
Section titled “Usage Examples”import { HttpCode, get } from 'shokupan';
export const getResource = get('/resource', () => { return { message: 'Permanent Redirect' };}).pipe(HttpCode(308));import { Controller, Get, HttpCode } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') @HttpCode(308) getResource() { return { message: 'Permanent Redirect' }; }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(308).json({ message: 'Permanent Redirect' });});import { Controller, Get, HttpCode } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') @HttpCode(308) getResource() { return { message: 'Permanent Redirect' }; }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 308; ctx.body = { message: 'Permanent Redirect' }; }});