Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

PodeRouteGroup with a file path #1329

Open
eltyBelgium opened this issue Jun 7, 2024 · 0 comments · May be fixed by #1331
Open

PodeRouteGroup with a file path #1329

eltyBelgium opened this issue Jun 7, 2024 · 0 comments · May be fixed by #1331
Assignees

Comments

@eltyBelgium
Copy link

Question

Is the following possible on any way?

Server.ps1

 Add-PodeRouteGroup -Path '/network' -FilePath './Routes/File.ps1'

File.ps1

{
    Add-PodeRoute -Method Get -Path '/domains' -ScriptBlock {
        $result = vsz-getdomains | ConvertTo-Json

        Write-PodeJsonResponse -Value $result
    }

    Add-PodeRoute -Method Get -Path '/zones' -ScriptBlock {
        $result = vsz-getzones | ConvertTo-Json

        Write-PodeJsonResponse -Value $result
    }

    Add-PodeRoute -Method Get -Path '/zones/:zoneId/wlans' -ScriptBlock {
        $result = vsz-getwlans $WebEvent.Parameters['zoneId']| ConvertTo-Json

        $specificWlan = $result | Where-Object { $_.ZoneID -eq $WebEvent.Query['wlandId'] }

        if($null -eq $specificWlan) {
            Write-PodeJsonResponse -Value $result
            
        }else{
            Write-PodeJsonResponse -Value $specificWlan
        }
    }

    Add-PodeRoute -Method Get -Path '/zones/:zoneId/dpsks' -ScriptBlock {
        $result = vsz-getdpsks $WebEvent.Parameters['zoneId']| ConvertTo-Json

        $specificWlan = $result | Where-Object { $_.ZoneID -eq $WebEvent.Query['dpsk'] }

        if($null -eq $specificWlan) {
            Write-PodeJsonResponse -Value $result
            
        }else{
            Write-PodeJsonResponse -Value $specificWlan
        }
    }

    Add-PodeRoute -Method Post -Path '/zones/:zoneId/dpsks' -ScriptBlock {

        try{
            $result = vsz-createdpsks -zoneID $WebEvent.Parameters['zoneId'] -wlanID $WebEvent.Data.wlandID -username $WebEvent.Data.username -userrole $WebEvent.Data.userrole
            Write-PodeTextResponse -Value $result -ContentType "application/json"
        }
        catch{
            Write-PodeErrorLog -Exception $_.Exception
            Write-PodeJsonResponse -Value @{"message" = $_.Exception.Message} -StatusCode 500
        }

    }
}
eltyBelgium pushed a commit to eltyBelgium/Pode that referenced this issue Jun 7, 2024
@Badgerati Badgerati linked a pull request Jun 12, 2024 that will close this issue
Badgerati added a commit to eltyBelgium/Pode that referenced this issue Jul 9, 2024
eltyBelgium added a commit to eltyBelgium/Pode that referenced this issue Nov 18, 2024
eltyBelgium added a commit to eltyBelgium/Pode that referenced this issue Jan 1, 2025
eltyBelgium added a commit to eltyBelgium/Pode that referenced this issue Feb 1, 2025
eltyBelgium added a commit to eltyBelgium/Pode that referenced this issue Feb 6, 2025
Badgerati added a commit to eltyBelgium/Pode that referenced this issue Feb 21, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants