< Back

Add-PodeMiddleware

Sat Jan 18, 2020 7:13 pm

NAME Add-PodeMiddleware



SYNOPSIS

Adds a new Middleware to be invoked before every Route, or certain Routes.





SYNTAX

Add-PodeMiddleware -Name <String> -ScriptBlock <ScriptBlock> [-Route <String>] [-ArgumentList <Object[]>]

[<CommonParameters>]



Add-PodeMiddleware -Name <String> -InputObject <Hashtable> [-Route <String>] [-ArgumentList <Object[]>]

[<CommonParameters>]





DESCRIPTION

Adds a new Middleware to be invoked before every Route, or certain Routes.





PARAMETERS

-Name <String>

The Name of the Middleware.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ScriptBlock <ScriptBlock>

The Script defining the logic of the Middleware.



Required? true

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-InputObject <Hashtable>

A Middleware HashTable from New-PodeMiddleware, or from certain other functions that return Middleware as a

HashTable.



Required? true

Position? named

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Route <String>

A Route path for which Routes this Middleware should only be invoked against.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



-ArgumentList <Object[]>

An array of arguments to supply to the Middleware's ScriptBlock.



Required? false

Position? named

Default value

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



-------------------------- EXAMPLE 1 --------------------------



PS C:\\>Add-PodeMiddleware -Name 'BlockAgents' -ScriptBlock { /* logic */ }













-------------------------- EXAMPLE 2 --------------------------



PS C:\\>Add-PodeMiddleware -Name 'CheckEmailOnApi' -Route '/api/*' -ScriptBlock { /* logic */ }















RELATED LINKS