Function redirect

Creates a redirect response.

  • Parameters

    • location: string

      The URL to which the client should be redirected.

    • status: number = 302

      The HTTP status code for the redirect, defaults to 302.

    • options: ResponseInit = {}

      Optional response initialization options.

    Returns Response

    A Response object with the redirect information.

    Example usage:

    import { start, router, redirect, text } from "@pulsar-http/core";

    const routes = [
    router.get("/old", async () => redirect("/new")),
    router.get("/new", async () => text("New Page")),
    ];

    start({ routes });