Skip to content

Commit 38514b6

Browse files
feat: Server101 Error Support ( Fixes #18 )
Aliasing parameters
1 parent 5ad9484 commit 38514b6

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

Servers/Server101.ps1

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#>
99
param(
1010
# The Root Directory
11-
[string]$RootPath = $(if ($PSScriptRoot) {$PSScriptRoot } else { $pwd }),
11+
[Alias('RootDirectory')][string]$RootPath =
12+
$(if ($PSScriptRoot) {$PSScriptRoot } else { $pwd }),
1213

1314
# The rootUrl of the server. By default, a random loopback address.
1415
[string]$RootUrl="http://127.0.0.1:$(Get-Random -Minimum 4kb -Maximum 42kb)/",
@@ -23,11 +24,10 @@ param(
2324
".ps1" = "text/x-powershell"
2425
})
2526

26-
$httpListener = [Net.HttpListener]::new()
27-
$httpListener.Prefixes.Add($RootUrl)
27+
$httpListener = [Net.HttpListener]::new();$httpListener.Prefixes.Add($RootUrl)
2828
Write-Warning "Listening on $RootUrl $($httpListener.Start())"
29-
30-
$io = [Ordered]@{ # Pack our job input into an IO dictionary
29+
# Pack our job input into an IO dictionary
30+
$io = [Ordered]@{
3131
HttpListener = $httpListener ; ServerRoot = $RootPath
3232
Files = [Ordered]@{}; ContentTypes = [Ordered]@{}
3333
}
@@ -62,14 +62,12 @@ Start-ThreadJob -ScriptBlock {param([Collections.IDictionary]$io)
6262
filter outputError([int]$N) {
6363
$re.StatusCode = $N
6464
$localPath = "/$N.html";$file = $files[$LocalPath]
65-
if ($file) {outputFile}
66-
$re.Close()
65+
if ($file) {outputFile} else { $re.Close() }
6766
continue next
6867
}
6968
filter outputHeader {
7069
$re.Length=$files[$localPath].Length
71-
$re.Close()
72-
continue next
70+
$re.Close();continue next
7371
}
7472
filter outputFile {
7573
$reply.ContentType = $contentTypes[$localPath]

0 commit comments

Comments
 (0)