Instance Methodvapor 4.106.3Vapor

    redirect(to:type:)

    Creates a redirect Response.

    Redirect.swift:15

    This declaration has been renamed to Request.redirect(to:redirectType:).

    This declaration is deprecated.

    func redirect(to location: String, type: RedirectType) -> Response

    Parameters

    location

    The path to redirect to

    type

    The type of redirect to perform

    Returns

    A response that provides a redirect to the specified location

    router.get("redirect") { req in
        return req.redirect(to: "https://vapor.codes")
    }

    Set type to ‘.permanently’ to allow caching to automatically redirect from browsers. Defaulting to non-permanent to prevent unexpected caching.

    Other members in extension

    Types

    Type members

    Instance members