bognition 4 hours ago

No that’s not how this works. You register the middleware with your web framework and it gets called as part of all web requests before the request hits your endpoints. This allows you to trust that authentication has been called for all api calls

all2 a day ago

But that's ok because the calls are hidden from the programmer.

I'm not sure if my response is serious or tongue-in-cheek. Maybe a bit of both.

KPGv2 a day ago

> Because then you are calling middleware_caching_auth_broker() from 37 places

No you aren't. You aren't really calling it from anywhere. The framework you're using, which you aren't writing, is calling the registered middleware.

The topic here is complexity for the code structure because it's called from 37 different places. A registered middleware doesn't run into that issue because it doesn't get called anywhere that "code structure complexity" matters.

Your reasoning is isomorphic to "I'm calling a bit shift millions of times because I have written some code in a programming language." Technically true but not what we're talking about here.

  • philwelch a day ago

    That sounds like the programming equivalent to thinking that food just comes from the grocery store.

    • tsurba 20 hours ago

      And going to a grocery store instead of 37 individual farmers…?