< Back

ConvertTo-PodeRoute

Sat Jan 18, 2020 7:14 pm

NAME ConvertTo-PodeRoute



SYNOPSIS

Takes an array of Commands, or a Module, and converts them into Routes.





SYNTAX

ConvertTo-PodeRoute [[-Commands] <String[]>] [[-Module] <String>] [[-Method] <String>] [[-Path] <String>]

[[-Middleware] <Object[]>] [-NoVerb] [<CommonParameters>]





DESCRIPTION

Takes an array of Commands (Functions/Aliases), or a Module, and generates appropriate Routes for the commands.





PARAMETERS

-Commands <String[]>

An array of Commands to convert - if a Module is supplied, these Commands must be present within that Module.



Required? false

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



-Module <String>

A Module whose exported commands will be converted.



Required? false

Position? 2

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Method <String>

An override HTTP method to use when generating the Routes. If not supplied, Pode will make a best guess based

on the Command's Verb.



Required? false

Position? 3

Default value

Accept pipeline input? false

Accept wildcard characters? false



-Path <String>

An optional Path for the Route, to prepend before the Command Name and Module.



Required? false

Position? 4

Default value /

Accept pipeline input? false

Accept wildcard characters? false



-Middleware <Object[]>

Like normal Routes, an array of Middleware that will be applied to all generated Routes.



Required? false

Position? 5

Default value

Accept pipeline input? false

Accept wildcard characters? false



-NoVerb [<SwitchParameter>]

If supplied, the Command's Verb will not be included in the Route's path.



Required? false

Position? named

Default value False

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:\\>ConvertTo-PodeRoute -Commands @('Get-ChildItem', 'Get-Host', 'Invoke-Expression') -Middleware

(Get-PodeAuthMiddleware -Name 'auth-name' -Sessionless)













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



PS C:\\>ConvertTo-PodeRoute -Module Pester -Path '/api'













-------------------------- EXAMPLE 3 --------------------------



PS C:\\>ConvertTo-PodeRoute -Commands @('Invoke-Pester') -Module Pester















RELATED LINKS