Skip to content

Instantly share code, notes, and snippets.

@fearthecowboy
Created July 30, 2018 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fearthecowboy/6f6f7b72330f9e2b8b53fb1421f32781 to your computer and use it in GitHub Desktop.
Save fearthecowboy/6f6f7b72330f9e2b8b53fb1421f32781 to your computer and use it in GitHub Desktop.
HttpPipelineAppend
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