(un)expected behavior of 'Session' when registering services from dynamically loaded libs #615
|
Hi all, I found the docs on ntex::web::App::configure and wondered if that would also work with shared libraries. My idea was to
This kinda worked out great. The paths are all accessible and return the defined HttpResponse. The logger wrapper is working properly and enabling/disabling the services can be handled by the shared libraries. Problem with shared libs
Initial thoughts If anyone has a clue on why the session is not working and if that is expected behavior, please clarify. I'd really appreciate it! Defining the loader_function could look something like this:
Loading the loader_function might look like this: I've checked the cookies via both when directly registering the services and independently using the shared library: |
Replies: 5 comments 1 reply
|
you cannot specify middleware in |
|
After some more digging I came up with a potential reason (not a fix!) why that happens... There are three locations where the address has to match:
It seems like that a service handler loaded via shared lib receives a different Maybe there is some I am unable to demangle how the #[proc_macro_attribute] |
|
It seems like the problem was related to inconsistent TypeId between loader library and dynamically loaded lib. Calling Now it's up to figuring out on matching them. |
|
wow, i wouldn’t think about this possibility. i am not sure how to fix this |
|
With a lot of trial and error, I finally got it to work now... There are actually two possible solutions to this: A. Provide custom generic method including a hashing function to insert and get from the extentions inner HashMapThis kinda impacts performace just slightly, but depends if the function is B. Split the dependencies between main-crate and loaded-crate
Important Notes
And inside extentions.rs we can simply substitute |
With a lot of trial and error, I finally got it to work now... There are actually two possible solutions to this:
I'd really appreciate opinions regarding these.
A. Provide custom generic method including a hashing function to insert and get from the extentions inner HashMap
This kinda impacts performace just slightly, but depends if the function is
constor not. I used aCustomTypeIdstruct and used std::any::type_name::() for my unique identifier as a quick test. Tested this by adding thepathproperty inside the Cargo.toml to a local copy of all ntex libs. Even though the docs say fortype_namethat it isbest-effort, it worked out fine generating identical names.A better approach wou…