Closed connor-ricks closed 3 days ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 83.41%. Comparing base (
e78cde7
) to head (7f47c97
). Report is 156 commits behind head on main.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Added. 👍 Thanks for the review!
Description
This PR extends the supported functionality of the
MiddlewareFixedTypeBuilder
result builder.if-else
statement syntax in result buildersif
statement syntax in result buildersoptional
unwrapping statement syntax in result builders.for-loop
statement syntax in result buildersThe addition of these result builders also empowers
HummingbirdRouter
unlocking the ability forRouteBuilder
andRouterController
objects to make use of this conditional syntax as well.Conditional
if-else
,if
andoptional
statementsAdding support for conditional statements in result builders further enhances the ability to perform logical operations when composing your application's routes and middleware.
if-else
Some applications may want to conditionally add different middleware based on various properties or configurations of their application. In the below example, we utilize different logging middleware if we are running in release mode.
if
Some applications may want to conditionally add middleware based on various properties or configurations of their application. In the below example, we attach a middleware that exposes the internal errors of our application to aid in client side debugging during development.
optionals
Sometimes our middleware builders may have an optional middleware that they would like to render. In the below example, we build our middleware in a function that takes an optional
logger
. We unwrap the middleware and add it to the router if it exists.for-loop
Sometimes we may build middleware based on a provided set of data. In the below example, we add a series of tracking middleware based on the provided collection of
Tracker
objects.