You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
the middleware handler can only accept the input iris.Context. Is there any possibility the public session be used in the middleware?
sometimes i want to pass the data handled in the middleware to the controllers' handlers or pass the data handled in the controllers' handlers to the DoneMiddleware. Maybe I can pass param with context, but I don't know if the context used in middleware and controllers' handler is the same one. Besides, is mvc in iris support to do it with other method?
The text was updated successfully, but these errors were encountered:
Yes, the question is already answered on the issue you posted with v11.2.
At your first question, you can register the same *sessions.Session in your controller as a field and bind it, we have the _examples/mvc/session-controller example.
hello @kataras, thanks for your reply and sorry for not replaying immediately.
As the example shows, the session is registerd in the controllers. Iris provide the function as follows for registering *sessions.session in UserController.
However, i want to use the sessions in the middleware. Is middleware before the controller able to register the same session with some function in iris?
You can call .Start many times, you can store the variables in the Context.Values().Set/Get, you can create a middleware which accepts a Session dependency using the hero dependency container, so yes you can pass it in middleware as well.
background
I need to add some public operation before and after every request, which is depended on the session.
example
I Read the example about middleware giving as follows.
https://github.com/kataras/iris/tree/master/_examples/mvc/middleware.
question
The text was updated successfully, but these errors were encountered: