mirror of
https://codeberg.org/gothub/RandomInstance
synced 2024-12-06 19:16:49 +01:00
2e96148246
Signed-off-by: Odyssey <hi@odyssey346.dev>
38 lines
1.3 KiB
PowerShell
38 lines
1.3 KiB
PowerShell
Start-PodeServer {
|
|
# get docker environment variable
|
|
$docker = $env:DOCKER
|
|
|
|
if ($docker) {
|
|
Add-PodeEndpoint -Address * -Port 8080 -Protocol Http
|
|
} else {
|
|
Add-PodeEndpoint -Address localhost -Port 8080 -Protocol Http
|
|
}
|
|
|
|
Add-PodeRoute -Method Get -Path '/' -ScriptBlock {
|
|
Write-PodeJsonResponse -Value @{ Response = 'Hello World' }
|
|
}
|
|
|
|
Add-PodeRoute -Method Get -Path '/random' -ScriptBlock {
|
|
$instances = Invoke-WebRequest https://codeberg.org/gothub/gothub-instances/raw/branch/master/instances.json | ConvertFrom-Json
|
|
|
|
$instance = $instances | Get-Random
|
|
|
|
Move-PodeResponseUrl -Url $instance.link
|
|
}
|
|
|
|
Add-PodeRoute -Method Get -Path '/random/master' -ScriptBlock {
|
|
$instances = Invoke-WebRequest https://codeberg.org/gothub/gothub-instances/raw/branch/master/instances.json | ConvertFrom-Json
|
|
|
|
$instance = $instances | Where-Object { $_.branch -eq 'master' } | Get-Random
|
|
|
|
Move-PodeResponseUrl -Url $instance.link
|
|
}
|
|
|
|
Add-PodeRoute -Method Get -Path '/random/dev' -ScriptBlock {
|
|
$instances = Invoke-WebRequest https://codeberg.org/gothub/gothub-instances/raw/branch/master/instances.json | ConvertFrom-Json
|
|
|
|
$instance = $instances | Where-Object { $_.branch -eq 'dev' } | Get-Random
|
|
|
|
Move-PodeResponseUrl -Url $instance.link
|
|
}
|
|
} |