mirror of
https://codeberg.org/gothub/RandomInstance
synced 2024-12-06 19:16:49 +01:00
+31
@@ -0,0 +1,31 @@
|
||||
Start-PodeServer {
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user