When we dispatch each mojit, make sure that the context used is valid according to the dimensions.json. This is because the context is used as the key for some caching, so it's a bad practice to put arbitrary keys/values into it.
How do I surface the data from middleware to controller then?
Define custom dimension?
You can have the middleware attach the data to the request object, then have the controller use the "mojito-http-addon" and call ac.http.getRequest() to get that request object.
Ideally Mojito would have an official way to support this.
I kind of support your idea.
Noting that req is the only unique object per request (at NodeJS level).
May be a simple add-on "mojito-shared-addon" would do... add to request at middleware layer and access via addon.
Well, the name may not sound good!
guys, let's not pollute this issue, I have created a new issue #249 for the data sharing discussion.
@gvaish there are not custom dimensions in mojito, that's the whole point of this issue, so we can keep the context domain finite.
@drewfish Is this now implemented in the new Resource Store?
Yes. The new RS has a validateContext(ctx) method, and uses it liberally. That method throws an error if the context keys/values aren't found in dimensions.json.