Update src/router.ps1
This commit is contained in:
@@ -7,8 +7,45 @@ function Invoke-TasksCompleted {
|
|||||||
function Dispatch-Request {
|
function Dispatch-Request {
|
||||||
param($Context)
|
param($Context)
|
||||||
|
|
||||||
|
# Normalize path
|
||||||
$path = $Context.Request.Url.AbsolutePath.TrimStart('/')
|
$path = $Context.Request.Url.AbsolutePath.TrimStart('/')
|
||||||
|
|
||||||
|
# Normalize path
|
||||||
|
$path = $Context.Request.Url.AbsolutePath.TrimStart('/')
|
||||||
|
|
||||||
|
switch -Regex ($path) {
|
||||||
|
|
||||||
|
'^$' {
|
||||||
|
# /
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyHtmlUrl -ContentType 'text/html; charset=utf-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
'^samy\.js$' {
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyJsUrl -ContentType 'application/javascript; charset=utf-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
'^samy\.css$' {
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyCssUrl -ContentType 'text/css; charset=utf-8'
|
||||||
|
}
|
||||||
|
|
||||||
|
'^SVS_logo\.svg$' {
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyTopLogoUrl -ContentType 'image/svg+xml'
|
||||||
|
}
|
||||||
|
|
||||||
|
'^SAMY\.png$' {
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyBgLogoUrl -ContentType 'image/png'
|
||||||
|
}
|
||||||
|
|
||||||
|
'^SVS_Favicon\.ico$' {
|
||||||
|
return Send-RemoteAsset -Context $Context -Url $Script:SamyFaviconUrl -ContentType 'image/x-icon'
|
||||||
|
}
|
||||||
|
|
||||||
|
default {
|
||||||
|
# Continue into your existing API/task routing
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($path -eq 'quit') {
|
if ($path -eq 'quit') {
|
||||||
Write-LogHybrid "Shutdown requested" "Info" "Server" -LogToEvent
|
Write-LogHybrid "Shutdown requested" "Info" "Server" -LogToEvent
|
||||||
Send-Text $Context "Server shutting down."
|
Send-Text $Context "Server shutting down."
|
||||||
|
|||||||
Reference in New Issue
Block a user