Skip to content

Latest commit

 

History

History
25 lines (22 loc) · 813 Bytes

Controllers.md

File metadata and controls

25 lines (22 loc) · 813 Bytes

Controllers

Since there's not really inherintance (its a good thing). we have to use a different way to make controllers.

Creating a controller

struct Controller {
    // ...
    bs: BaseController // Some sort of base controller which we can implement the db and templating
} 

impl Routing for Controller { // This is the important part which allows us to use the router to route to this controller..... but idk if this is the best way to do it
    fn routes(&self) -> Vec<Route> {
        vec![
            Route::new("/path", "GET", Self::function),
        ]
    }
}
impl Controller {
    pub fn function(&self, /* Still not final but idk yet */) -> String {
        // ...
        self.bs.template("template_name", data /* I have no idea what i want here but probably this....*\);
    }
}