Skip to content
Open
45 changes: 40 additions & 5 deletions src/Public/Routes.ps1
Comment thread
eltyBelgium marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,14 @@ An 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.

.PARAMETER FilePath
A literal, or relative, path to a file containing a ScriptBlock for the Route's main logic.

.EXAMPLE
Add-PodeRouteGroup -Path '/api' -Routes { Add-PodeRoute -Path '/route1' -Etc }

.EXAMPLE
Add-PodeRouteGroup -Path '/api' -FilePath '/routes/file.ps1'
#>
function Add-PodeRouteGroup {
[CmdletBinding()]
Expand Down Expand Up @@ -1164,11 +1170,23 @@ function Add-PodeRouteGroup {
$AllowAnon,

[string[]]
$OADefinitionTag
$OADefinitionTag,

[Parameter(Mandatory = $true, ParameterSetName = 'file')]
Comment thread
eltyBelgium marked this conversation as resolved.
Outdated
[string]
$FilePath
)



if (Test-PodeIsEmpty $Routes) {
throw 'No scriptblock for -Routes passed'
if ($PSCmdlet.ParameterSetName -ieq 'file') {
$Routes = Convert-PodeFileToScriptBlock -FilePath $FilePath
}
else {

throw 'No scriptblock for -Routes passed'
}
}

if ($Path -eq '/') {
Expand Down Expand Up @@ -1567,8 +1585,14 @@ The EndpointName of an Endpoint(s) to use for the Signal Routes.
.PARAMETER IfExists
Specifies what action to take when a Signal Route already exists. (Default: Default)

.PARAMETER FilePath
A literal, or relative, path to a file containing a ScriptBlock for the Route's main logic.

.EXAMPLE
Add-PodeSignalRouteGroup -Path '/signals' -Routes { Add-PodeSignalRoute -Path '/signal1' -Etc }

.EXAMPLE
Add-PodeSignalRouteGroup -Path '/api' -FilePath '/routes/file.ps1'
#>
function Add-PodeSignalRouteGroup {
[CmdletBinding()]
Expand All @@ -1588,11 +1612,22 @@ function Add-PodeSignalRouteGroup {
[Parameter()]
[ValidateSet('Default', 'Error', 'Overwrite', 'Skip')]
[string]
$IfExists = 'Default'
$IfExists = 'Default',

[Parameter(Mandatory = $true, ParameterSetName = 'file')]
Comment thread
eltyBelgium marked this conversation as resolved.
Outdated
[string]
$FilePath
)

i
Comment thread
eltyBelgium marked this conversation as resolved.
Outdated
if (Test-PodeIsEmpty $Routes) {
throw 'No scriptblock for -Routes passed'
if ($PSCmdlet.ParameterSetName -ieq 'file') {
$Routes = Convert-PodeFileToScriptBlock -FilePath $FilePath
}
else {

throw 'No scriptblock for -Routes passed'
}
}

if ($Path -eq '/') {
Expand Down Expand Up @@ -2759,4 +2794,4 @@ function Test-PodeSignalRoute {

# check for routes
return (Test-PodeRouteInternal -Method $Method -Path $Path -Protocol $endpoint.Protocol -Address $endpoint.Address)
}
}