pub trait Action {
fn title(&mut self) -> String;
fn name(&mut self) -> String;
fn index(
&mut self,
header: JsonValue,
request: JsonValue,
tools: Tools
) -> Response;
fn token(&mut self) -> bool { ... }
fn public(&mut self) -> bool { ... }
fn extend(&mut self) -> Vec<&str> ⓘ { ... }
fn params(&mut self) -> JsonValue { ... }
fn _check(&mut self, request: JsonValue) -> (bool, String, JsonValue) { ... }
fn run(
&mut self,
header: JsonValue,
request: JsonValue,
tools: Tools
) -> Response { ... }
fn success(&mut self, data: JsonValue, msg: &str) -> Response { ... }
fn fail(&mut self, msg: &str) -> Response { ... }
fn login(&mut self, msg: &str) -> Response { ... }
}
Expand description
动作
Required Methods§
Provided Methods§
sourcefn run(&mut self, header: JsonValue, request: JsonValue, tools: Tools) -> Response
fn run(&mut self, header: JsonValue, request: JsonValue, tools: Tools) -> Response
执行参数入口
Examples found in repository?
examples/test.rs (lines 22-25)
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
fn main() {
let mut apimodel = plugin("tests").model("test").action("table");
let tools = {
let mut db_conf = object! {};
let mut cache_conf = object! {};
let mut kafka_conf = object! {};
df_plugin::Tools {
db: Db::new(db_conf.clone()),
cache: Cache::connect(cache_conf.clone()),
kafka: Kafka::connect(kafka_conf.clone()),
}
};
let data = apimodel.run(object! {}, object! {
page:1,
limit:10
}, tools);
println!("{:#}", data.to_json());
}