Day 18: Load middleware conditionally

Home DE Day 18: Load middleware conditionally

I’ve introduced a couple of middleware components. Some of them are useful and could be enabled globally, while others might be better enabled on certain conditions. Today we’ll talk about a solution to this. ### Load middleware conditionally Conditional middleware is a super (or meta) middleware that takes one middleware and enable that middleware based on a runtime condition. Let’s take some examples: * You want to enable [JSONP middleware]( only if the path begins with /public * You don’t want to enable [Basic Auth]( if the request comes from local IP We investigated how they deal with situations like…

Source :

Leave a Reply

Your email address will not be published.