Delete

The delete method will delete a specific file and will take its filename from a query parameter, as well as the JSON body. It uses a DELETE route, as you can see in the following code sample:

New-PolarisDeleteRoute -Path "/files" -Scriptblock {
$fileName = if ($request.Query['Name'])
{
$request.Query['Name']
}
elseif ($request.Body.Name)
{
$request.Body.Name
}
else
{
$response.SetStatusCode(501)
$response.Send("File name may not be empty.")
return
}

Remove-Item -Path (Join-Path $Request.PolarisPath -ChildPath $fileName)
} -Force

Start-Polaris

The delete method again takes either a JSON body or a query parameter. Start-Polaris runs the server on port 8080.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset