You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using custom functions in middleware, which return an Write-Output seems to force Middleware to return $true, even through there is explicit return $false statement in the Logic. Forwarding function to Out-Null resolves the isssue.
Is this expected behaviour?
Environment:
Pode v2.11.0
PSVersion 7.4.2
Microsoft Windows 10.0.20348
Replication data:
----- Custom function ----
function Test-WriteMiddlewareoutput ($a) {
Write-Output -InputObject $a
}
function Test-WriteMiddlewareToFile ($path) {
'Test' | Out-File -LiteralPath $path -Force
}
------ Pode Host -----
pode start
Pode v2.11.0 (PID: 8108)
Listening on the following 1 endpoint(s) [1 thread(s)]:
- http://localhost:8084/
Should return false -output
Should return false -toFIle
Thank you very much for your answer.
Best Regards,
Ondrej
The text was updated successfully, but these errors were encountered:
This is expected, Write-Output returns data back up the pipe; so even though there is a $false later on, the function is actually returning $a and $false, which will be seen as an array of items and treated as $true - i.e. it's a non-empty array of items.
Doing Write-Output -InputObject $a | Out-Null will fix it, as you've started. You could also use Out-Default or Out-PodeHost:
Using custom functions in middleware, which return an Write-Output seems to force Middleware to return $true, even through there is explicit return $false statement in the Logic. Forwarding function to Out-Null resolves the isssue.
Is this expected behaviour?
Environment:
Pode v2.11.0
PSVersion 7.4.2
Microsoft Windows 10.0.20348
Replication data:
----- Custom function ----
------ Server code --------
-------------- API call ------
------ Pode Host -----
pode start
Pode v2.11.0 (PID: 8108)
Listening on the following 1 endpoint(s) [1 thread(s)]:
- http://localhost:8084/
Should return false -output
Should return false -toFIle
Thank you very much for your answer.
Best Regards,
Ondrej
The text was updated successfully, but these errors were encountered: