Created
July 30, 2018 16:40
-
-
Save fearthecowboy/6f6f7b72330f9e2b8b53fb1421f32781 to your computer and use it in GitHub Desktop.
HttpPipelineAppend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get-Redis -HttpPipelineAppend { param($req, $callback, $next ) | |
Write-Host -fore white "Inserted my code in the http pipeline on the way to:`n` $($req.RequestUri)." | |
Write-Host -fore yellow "`n---------------------`n Before We Go!`n---------------------" | |
Write-host -fore white "Request Headers:"; | |
$($req.Headers) |% { if ($_.Key -ne "Authorization") { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" } } | |
# call the next step in the Pipeline | |
$responseTask = $next.SendAsync($req, $callback) | |
# wait on the responseTask | |
$response = $responseTask.Result | |
# after the call... | |
Write-Host -fore yellow "`n---------------------`nWe're back!`n---------------------" | |
# Peek into the http response before it goes to the cmdlet for processing | |
Write-host -fore white "Response Headers:"; | |
$($response.Headers) |% { Write-host -nonewline -fore cyan " $($_.Key): "; Write-Host -fore green "$($_.Value)" } | |
# let the cmdlet finish it's job | |
return $responseTask | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment