Comments (5)
As before request middleware is called without a response, this middleware will have to be after request middleware, which is a problem, because essentially none of the drash logic should need to run as when the request hits the web server, this middleware is going to return a response very early. for example:
How it would work now
- Drash gets a request
- runs all the logic around if request is for a resource etc
- runs the after request middleware
How it should work
- Drash gets request
- calls before request middleware, passing in response object
- this middleware runs, checks if request is for a static asset
- if it is, sends the response the client
- drash doesnt need to run any other logic, the middleware handles it all in this scenario
from deno-drash-middleware.
I understand that the response param in the middleware being a way to tell us if the request is before or ater, but maybe we should add an extra param instead so the response is always passed in
type MiddlewareFunction = (request: ..., response: ..., type: "before" | "after") => void
from deno-drash-middleware.
we could add an extra param so the response is always passed in, but i can't remember why we didn't do that
from deno-drash-middleware.
As before request middleware is called without a response, this middleware will have to be after request middleware, which is a problem, because essentially none of the drash logic should need to run as when the request hits the web server, this middleware is going to return a response very early. for example:
How it would work now
- Drash gets a request
- runs all the logic around if request is for a resource etc
- runs the after request middleware
How it should work
- Drash gets request
- calls before request middleware, passing in response object
- this middleware runs, checks if request is for a static asset
- if it is, sends the response the client
- drash doesnt need to run any other logic, the middleware handles it all in this scenario
you're right. damnit. so drash short-circuits all of the logic based on the request extension. if it has a .txt or .png or .jpg or whatever, then it knows the request is for a static asset. from there it goes "alrigh we don't have to execute the resource logic... just short-circuit this request and send the static asset". however, we don't have that kind of logic in middleware, so we'd need to add that logic... and it would possibly be a breaking change.
from deno-drash-middleware.
related PR is: drashland/drash#503
we'd have to use response.send() in this middleware to end the lifecycle
But we're in talks of removing the need for servestatic and using a resource inctead, so this comment might make no difference, but its here for reference regardless
from deno-drash-middleware.
Related Issues (20)
- Pls Deps LoggerService error 404 HOT 4
- Update Rhum to latest
- Readme not being updated? HOT 1
- Tornado middleware HOT 1
- Paladin - clean up large function HOT 2
- Tengine - A template engine middleware HOT 2
- Tengine - Add support for the Eta template engine HOT 13
- Video Tutorial - Template Engine HOT 2
- CSRF: Allow Cookie HOT 1
- ServeTypeScript compile time middleware
- Response ETag Header HOT 15
- Drash Middleware v0.6.0 (Release Date: 11-05-2020) HOT 1
- Why Do The Docs Specify Eta v1.6.0 HOT 5
- Tengine - Incorrectly referencing Drash
- CORS - Write CORS middleware tutorial
- Tengine - Write Jae tutorials
- unexpected status was thrown for no-token/invalid-token cases
- ServeTypeScript import statement only imports a single file HOT 6
- Write Tests for Tengine
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deno-drash-middleware.