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

Stop passing the WebEvent parameter, so it can be used generally #621

Merged
merged 4 commits into from
Nov 1, 2020

Conversation

Badgerati
Copy link
Owner

Description of the Change

The Web Event object is the first parameter supplied to the ScriptBlocks of Routes, Middleware, and Endware. These already all have access to the main $WebEvent object, including Authentication, without the need to supply it as a parameter.

Therefore, to help keep code shorter/cleaner, the event should stop being supplied as the first parameter, and instead documented to just be accessed via $WebEvent.

This change applies to Routes, Middleware, Endware, and Authentication. (Also the the $SmtpEvent when using the SMTP Server)

Related Issue

Resolves #618

Examples

So from the following:

Add-PodeRoute -Method Get -Path '/' -ScriptBlock {
    param($e)
    Write-PodeJsonResponse -Value @{ Result = $e.Data['value']}
}

To this:

Add-PodeRoute -Method Get -Path '/' -ScriptBlock {
    Write-PodeJsonResponse -Value @{ Result = $WebEvent.Data['value']}
}

@Badgerati Badgerati added this to the 2.0.0 milestone Nov 1, 2020
@Badgerati Badgerati self-assigned this Nov 1, 2020
@Badgerati Badgerati merged commit 3f7fd9f into develop Nov 1, 2020
@Badgerati Badgerati deleted the Issue-618 branch November 1, 2020 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop pointlessly passing the WebEvent argument
1 participant