Skip to content

Support for Endpoint filtering on global Middleware #1560

Description

@Badgerati

Describe the Change

As raised on Discord, it would be nice if functions like Add-PodeMiddleware and Add-PodeAuthMiddleware has support for an -EndpointName parameter.

This would let people create global Middleware for all Routes, but also be able to filter down to only Routes running on specific Endpoints.

Use Cases

  1. If you have 2 Endpoints, and you want to apply 2 different global authentications - 1 per auth. Today, you'd have to apply those auths manually to every Route; but if we has -EndpointName we could apply the auths at a global level for all Routes but filtering to the required ones on specific endpoints.

Notes

  • We should be able to add -EndpointName to both functions mentioned, and make them a string[]. Then in Invoke-PodeMiddleware, we filter using the current $WebEvent.Endpoint.Name - would can reference $WebEvent directly or pass it as a parameter.
  • If no -EndpointName is supplied, the Middleware runs for every Route - the default, and the current logic today.
  • Need to check other Middleware functions, to make sure the addition of an optional -EndpointName doesn't break anything - or if other functions could make use of it.

No activity

Activity on this issue will appear here.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions