It is not quite clear for me about the definition, functions and the neccessity of middleware in web development.
Can anyone have a clear explanation about what this is and why we need it in a web project?
Thank you!
It is not quite clear for me about the definition, functions and the neccessity of middleware in web development.
Can anyone have a clear explanation about what this is and why we need it in a web project?
Thank you!
For further actions, you may consider blocking this person and/or reporting abuse
arjun -
Gabor Szabo -
Matthew Evan Eichler -
Hamza Khan -
Top comments (2)
Imagine a conveyor in a Santa toy factory. One elf is dedicated to sorting broken toys out, the next one paints the toys, the third one packs them and so on. Each elf is a middleware.
On each incoming message middleware can either intercept it or modify it and pass it to the next middleware.
A Middleware is a bit of code (can be a function or another application) that executes before the code meant to handle a given operation.
Imagine a classic setup where you have a some controllers each handling a given uri.
To make sure there authentication check for all of them, instead of beginning each controller with an if 'authenticated' do this else return unauthorized, you would use a Middleware which would return the unauthorized early else pass execution to your controller.
In frameworks this is usually done for you behind the scenes via configuration in some common cases