Comments (3)
I'm of the opinion that it is something we definitely want to do.
Having middleware without this just makes middleware unviable.
The reason being that something like an authentication middleware definitely requires being able to pass information to the controller.
That said I think in most applications one or two standard middleware will be all that's required. i.e. I don't think the average project should be defining many/any middleware.
The protocol upgrade stuff is interesting but I don't have anything useful to add. I'm not even sure it's worth giving much thought until someone tries implementing websockets or similar (if similar even exists, Is there anything like websockets but not websockets?)
My current goal is to go through the list of middleware that it would be nice to have (it exists on the raxx_kit proposals board) use the Process dictionary as need be and see what falls out.
The way I see it there are two questions
- structured/unstructured for the data
- Process dictionary or parameters for passing around.
I am leaning to process dictionary because if a middleware doesn't need to do anything with the context. For example imagine the following stack
Raxx.Session
MyNewMiddleware
Raxx.Flash
The flash middleware will need a few things from the session middleware, and the session middleware will need to know what was added/deleted by the flash middleware in the response.
Using the process dictionary allows MyNewMiddleware
to be oblivious to the fact a context even exists
from raxx.
I thought about it some more and I am starting to believe putting it in the process dictionary is the way to go. Adding it to the behaviours would complicate them a fair bit, without much benefit in most situations.
You're right, probably not much point trying to fit in protocol upgrade at this point.
The implementation should be simple enough, the bulk of the task is going to be providing a good API for it. I think it makes sense for me to build up a PR with some working implementation and we can discuss the interface based on it.
from raxx.
The problem with the process dictionary I've hit with context is propagating to another process when needed.
For now I've simply gone with providing both options, process dictionary context or variable context. If you use the pdict context and want to propagate you must get the current context into a variable and pass it as part of a message.
Personally in the case of middlewares like this I'd go with a variable. We've discussed doing this in Elli and it is the way I do it in grpcbox.
from raxx.
Related Issues (20)
- Add middleware proof of concept HOT 10
- Remove handle_request from Raxx.Server behaviour HOT 2
- Should setting a body on a GET request raise an error. HOT 1
- Benchmark different Raxx.Stack state structures and switch to the fastest one HOT 1
- Add a Middleware-aware Router HOT 5
- make `use Raxx.Middleware` a thing HOT 2
- allow to set multiple cookies HOT 5
- New 1.0 roadmap HOT 11
- Remove eex_html dep? HOT 5
- Handle unexpected HTTP verb HOT 6
- Incorrect parsing of request when path looks like an absolute url HOT 1
- Raxx.Session 1.0 Roadmap
- Raxx.View 1.0 Roadmap
- Raxx.Logger 1.0 Roadmap
- can we have both server streaming and simple request/response in same module?
- Fix specs, to show that Raxx.data can contain iodata
- Gleam HOT 6
- Raxx.View add a way to have page metadata in the layout
- Project status? HOT 1
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 raxx.