Skip to content
This repository has been archived by the owner on Dec 8, 2021. It is now read-only.

New RouteMiddleware

Tyler James Leonhardt edited this page Oct 26, 2017 · 1 revision

New-RouteMiddleware

SYNOPSIS

Add a new route middleware.

SYNTAX

New-RouteMiddleware [-Name] <String> [[-ScriptBlock] <ScriptBlock>] [-ScriptPath <String>]

DESCRIPTION

Route middleware is used to manipulate request and response objects before it makes it to your route logic.

EXAMPLES

$JsonBodyParserMiddlerware = {
    if ($Request.BodyString -ne $null) {
        $Request.Body = $Request.BodyString | ConvertFrom-Json
    }
}

New-RouteMiddleware -Name JsonBodyParser -ScriptBlock $JsonBodyParserMiddleware

PARAMETERS

-Name

The name of the middleware.

-ScriptBlock

The middleware script block that will be executed

-ScriptPath

A path to the middleware script that will be executed