Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: "middleware" mechanism #217

Open
kazimuth opened this issue Feb 25, 2019 · 1 comment
Open

Feature request: "middleware" mechanism #217

kazimuth opened this issue Feb 25, 2019 · 1 comment

Comments

@kazimuth
Copy link
Contributor

kazimuth commented Feb 25, 2019

I've been noticing it might reduce boilerplate to have something where you could create a "middleware" for each web framework, that would automatically set some properties of templates rendered beneath it. e.g. in actix:

App::new()
   .middleware(LoginMiddleware)
   .resource("/", |r| r.h(|_| FrontPageTemplate { ... }))
   .resource("/control_panel", |r| r.h(|_| ControlPanelTemplate { ... }));

and have the username field of those templates automatically set to the user's name if they're logged in.

No idea how the hell this could be implemented, especially without too much type tetris.

Maybe with #184 where there's a base template populated somehow that other templates extend?

This could be useful for #211 for providing locale-parsing middlewares.

@djc
Copy link
Owner

djc commented Mar 4, 2019

Hmm, not sure I see it. What you can easily do is have a Meta type that you put in all the other template contexts and which you pass to views so that they can put it in there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants