Git Product home page Git Product logo

Comments (4)

SergioBenitez avatar SergioBenitez commented on May 3, 2024

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.

from rocket.

aniljava avatar aniljava commented on May 3, 2024

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.

from rocket.

stephanbuys avatar stephanbuys commented on May 3, 2024

@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.

from rocket.

SergioBenitez avatar SergioBenitez commented on May 3, 2024

@stephanbuys That's right. :)

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

from rocket.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.