Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Routes order #1247

Open
mdaneri opened this issue Mar 4, 2024 · 0 comments
Open

Routes order #1247

mdaneri opened this issue Mar 4, 2024 · 0 comments

Comments

@mdaneri
Copy link
Contributor

mdaneri commented Mar 4, 2024

Is there a reason why static routes are checked before any non-static ones?
The question is related to this sample: ( $directoryPath is the PodePath)

# Start Pode server
Start-PodeServer -ScriptBlock {

    Add-PodeEndpoint -Address localhost -Port 8080 -Protocol Http -Default
   Add-PodeRoute -Method Get -Path '/LICENSE.txt' -ScriptBlock {
        $value=@"
Don't be kidding. Nobody will believe that you want to read this legalise nonsense.
I want to be kind; this is a summary of the content:

Nothing to report :D
"@
        Write-PodeTextResponse -Value $value
    }
    Add-PodeStaticRouteGroup -FileBrowser  -Routes {
        Add-PodeStaticRoute -Path '/' -Source $using:directoryPath -FileBrowser  
    }
}

in theory, the code should hide the LICENSE.TXT file, but today, this code is not working because Static routes are checked before
anything else.

It is a problem if we switch the order Static->Anything else to Anything else ->Static. Or at least make this configurable.

I did some tests and cannot see any side effects from changing that.

@Badgerati, what are your thoughts?

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant