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

Plugin support? #40

Closed
Anachron opened this issue Dec 24, 2016 · 4 comments
Closed

Plugin support? #40

Anachron opened this issue Dec 24, 2016 · 4 comments
Labels
duplicate This issue or pull request already exists enhancement A minor feature request request Request for new functionality

Comments

@Anachron
Copy link

Do you plan to allow for pluggable features, such as an administrator UI that could be activated by simply adding 'rocket.register_plugin'?

I am thinking about a system where users have it easy to add or remove a feature (plugin) without having too much stuff to do.

In my mind plugins would have a init method which would do all the stuff a user would normally do to glue the code.

@SergioBenitez
Copy link
Member

Many of the things you'd use "plugins" for in other frameworks you can already do with Rocket. For example, you might imagine a library that exposes many "admin panel" routes. Then, your application could simply configure that library and mount those routes. That would look something like this:

fn main() {
    let admin_routes = AdminLibrary::config(param, param, ..);
    rocket::ignite().mount("/admin", admin_routes).launch();
}

You could even get rid of the AdminLibrary::config step if the library is amenable to being configured via Rocket.toml extra parameters, as discussed in the API docs. This is something you can do today, and it doesn't introduce another concept.

I don't have a high opinion of catch-all ideas like plugins and middleware. I'd rather find a solution that works very well for a few things rather than poorly for most things. Many of the things that might lead you to reach for plugins or middleware elsewhere can already be done with Rocket in a different, usually cleaner and more focused way. I'd like to keep the concepts to a minimum.

@SergioBenitez SergioBenitez added request Request for new functionality enhancement A minor feature request labels Dec 24, 2016
@aniljava
Copy link

aniljava commented Dec 25, 2016

There are some use cases like response compression, filters that are applicable for multiple routes (auth, logging, response header alterations .. ). middlewares i think are better fit. But being a rust newbie, i cant rule out if there are language features to achieve the same thing. Any suggestions how these things are going to be addressed.

@stephanbuys
Copy link
Contributor

stephanbuys commented Dec 25, 2016

@SergioBenitez I'm quite interested in using JWT - would a plugin be required for it?

Edit - just APIKey example, I'm guessing that's the road to pursue.

@SergioBenitez
Copy link
Member

@stephanbuys That's right. :)

Okay, so looks like we're really talking about middleware here. Closing in favor of #55.

@SergioBenitez SergioBenitez added the duplicate This issue or pull request already exists label Mar 9, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists enhancement A minor feature request request Request for new functionality
Projects
None yet
Development

No branches or pull requests

4 participants