Add PodeRoute - mdaneri/Pode GitHub Wiki
Adds a Route for a specific HTTP Method(s).
Add-PodeRoute -Method <String[]> -Path <String> [-Middleware <Object[]>] [-ScriptBlock <ScriptBlock>]
[-EndpointName <String[]>] [-ContentType <String>] [-TransferEncoding <String>] [-ErrorContentType <String>]
[-ArgumentList <Object[]>] [-Authentication <String>] [-Access <String>] [-IfExists <String>]
[-Role <String[]>] [-Group <String[]>] [-Scope <String[]>] [-User <String[]>] [-AllowAnon] [-Login] [-Logout]
[-OAResponses <Hashtable>] [-OAReference <String>] [-PassThru] [-OADefinitionTag <String[]>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Add-PodeRoute -Method <String[]> -Path <String> [-Middleware <Object[]>] [-EndpointName <String[]>]
[-ContentType <String>] [-TransferEncoding <String>] [-ErrorContentType <String>] -FilePath <String>
[-ArgumentList <Object[]>] [-Authentication <String>] [-Access <String>] [-IfExists <String>]
[-Role <String[]>] [-Group <String[]>] [-Scope <String[]>] [-User <String[]>] [-AllowAnon] [-Login] [-Logout]
[-OAResponses <Hashtable>] [-OAReference <String>] [-PassThru] [-OADefinitionTag <String[]>]
[-ProgressAction <ActionPreference>] [<CommonParameters>]
Adds a Route for a specific HTTP Method(s), with path, that when called with invoke any logic and/or Middleware.
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { /* logic */ }
Add-PodeRoute -Method Post -Path '/users/:userId/message' -Middleware (Get-PodeCsrfMiddleware) -ScriptBlock { /* logic */ }
Add-PodeRoute -Method Post -Path '/user' -ContentType 'application/json' -ScriptBlock { /* logic */ }
Add-PodeRoute -Method Post -Path '/user' -ContentType 'application/json' -TransferEncoding gzip -ScriptBlock { /* logic */ }
Add-PodeRoute -Method Get -Path '/api/cpu' -ErrorContentType 'application/json' -ScriptBlock { /* logic */ }
Add-PodeRoute -Method Get -Path '/' -ScriptBlock { /* logic */ } -ArgumentList 'arg1', 'arg2'
Add-PodeRoute -Method Get -Path '/' -Role 'Developer', 'QA' -ScriptBlock { /* logic */ }
$Responses = New-PodeOAResponse -StatusCode 400 -Description 'Invalid username supplied' |
New-PodeOAResponse -StatusCode 404 -Description 'User not found' |
New-PodeOAResponse -StatusCode 405 -Description 'Invalid Input'
Add-PodeRoute -PassThru -Method Put -Path '/user/:username' -OAResponses $Responses -ScriptBlock { #code is going here }
The name of an Access method which should be used as middleware on this Route.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseIf supplied, the Route will allow anonymous access for non-authenticated users.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseAn array of arguments to supply to the Route's ScriptBlock.
Type: Object[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe name of an Authentication method which should be used as middleware on this Route.
Type: String
Parameter Sets: (All)
Aliases: Auth
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe content type the Route should use when parsing any payloads.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe EndpointName of an Endpoint(s) this Route should be bound against.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe content type of any error pages that may get returned.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA literal, or relative, path to a file containing a ScriptBlock for the Route's main logic.
Type: String
Parameter Sets: File
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOne or more optional Groups that will be authorised to access this Route, when using Authentication with an Access method.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseSpecifies what action to take when a Route already exists. (Default: Default)
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: Default
Accept pipeline input: False
Accept wildcard characters: FalseIf supplied, the Route will be flagged to Authentication as being a Route that handles user logins.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseIf supplied, the Route will be flagged to Authentication as being a Route that handles users logging out.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThe HTTP Method of this Route, multiple can be supplied.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAn array of ScriptBlocks for optional Middleware.
Type: Object[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAn Array of strings representing the unique tag for the API specification. This tag helps in distinguishing between different versions or types of API specifications within the application. You can use this tag to reference the specific API documentation, schema, or version that your function interacts with.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA reference to OpenAPI reusable pathItem component created with Add-PodeOAComponentPathItem
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseAn alternative way to associate OpenApi responses unsing New-PodeOAResponse instead of piping multiple Add-PodeOAResponse
Type: Hashtable
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseIf supplied, the route created will be returned so it can be passed through a pipe.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: FalseThe URI path for the Route.
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False{{ Fill ProgressAction Description }}
Type: ActionPreference
Parameter Sets: (All)
Aliases: proga
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOne or more optional Roles that will be authorised to access this Route, when using Authentication with an Access method.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOne or more optional Scopes that will be authorised to access this Route, when using Authentication with an Access method.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseA ScriptBlock for the Route's main logic.
Type: ScriptBlock
Parameter Sets: Script
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThe transfer encoding the Route should use when parsing any payloads.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseOne or more optional Users that will be authorised to access this Route, when using Authentication with an Access method.
Type: String[]
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: FalseThis cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.