mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 16:03:31 +00:00
switched controller to commands file, added logger on init function
This commit is contained in:
35
src/commands.rs
Normal file
35
src/commands.rs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
pub(crate) mod markers {
|
||||||
|
use log::info;
|
||||||
|
|
||||||
|
pub fn get(placeholder: String) -> &'static str {
|
||||||
|
info!("{}", placeholder);
|
||||||
|
|
||||||
|
return "not implemented yet";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn post(placeholder: Vec<String>) -> &'static str {
|
||||||
|
for item in placeholder {
|
||||||
|
info!("Item: {}", item)
|
||||||
|
}
|
||||||
|
|
||||||
|
return "not implemented yet";
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn delete(placeholder: String) -> &'static str {
|
||||||
|
info!("{}", placeholder);
|
||||||
|
|
||||||
|
return "not implemented yet";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) mod casevac {
|
||||||
|
pub fn get(placeholder: String) -> String {
|
||||||
|
format!("ERROR: Not implemented yet, {}", placeholder)
|
||||||
|
}
|
||||||
|
pub fn post(placeholder: String) -> String {
|
||||||
|
format!("ERROR: Not implemented yet, {}", placeholder)
|
||||||
|
}
|
||||||
|
pub fn delete(placeholder: String) -> String {
|
||||||
|
format!("ERROR: Not implemented yet, {}", placeholder)
|
||||||
|
}
|
||||||
|
}
|
||||||
73
src/lib.rs
73
src/lib.rs
@@ -1,55 +1,48 @@
|
|||||||
use arma_rs::{arma, Extension, Group};
|
use arma_rs::{arma, Extension, Group};
|
||||||
|
use util::get_uuid;
|
||||||
|
mod commands;
|
||||||
|
mod services;
|
||||||
|
mod structs;
|
||||||
|
mod tests;
|
||||||
|
mod util;
|
||||||
#[arma]
|
#[arma]
|
||||||
pub fn init() -> Extension {
|
pub fn init() -> Extension {
|
||||||
|
use log4rs::append::file::FileAppender;
|
||||||
|
use log4rs::config::{Appender, Config, Root};
|
||||||
|
use log4rs::encode::pattern::PatternEncoder;
|
||||||
|
|
||||||
|
let file_appender = FileAppender::builder()
|
||||||
|
.append(true)
|
||||||
|
.encoder(Box::new(PatternEncoder::new("{d} {t} {l} - {m}{n}")))
|
||||||
|
.build("armatak.log")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let config = Config::builder()
|
||||||
|
.appender(Appender::builder().build("file", Box::new(file_appender)))
|
||||||
|
.build(
|
||||||
|
Root::builder()
|
||||||
|
.appender("file")
|
||||||
|
.build(log::LevelFilter::Info),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
log4rs::init_config(config).unwrap();
|
||||||
|
|
||||||
Extension::build()
|
Extension::build()
|
||||||
.command("uuid", get_uuid)
|
.command("uuid", get_uuid)
|
||||||
.group(
|
.group(
|
||||||
"markers",
|
"markers",
|
||||||
Group::new()
|
Group::new()
|
||||||
.command("get", markers::get)
|
.command("get", commands::markers::get)
|
||||||
.command("post", markers::post)
|
.command("post", commands::markers::post)
|
||||||
.command("delete", markers::delete),
|
.command("delete", commands::markers::delete),
|
||||||
)
|
)
|
||||||
.group(
|
.group(
|
||||||
"casevac",
|
"casevac",
|
||||||
Group::new()
|
Group::new()
|
||||||
.command("get", casevac::get)
|
.command("get", commands::casevac::get)
|
||||||
.command("post", casevac::post)
|
.command("post", commands::casevac::post)
|
||||||
.command("delete", casevac::delete),
|
.command("delete", commands::casevac::delete),
|
||||||
)
|
)
|
||||||
.finish()
|
.finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
mod tests;
|
|
||||||
mod structs;
|
|
||||||
|
|
||||||
fn get_uuid() -> String {
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
Uuid::new_v4().to_string()
|
|
||||||
}
|
|
||||||
|
|
||||||
mod markers {
|
|
||||||
pub fn get(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
pub fn post(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
pub fn delete(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
mod casevac {
|
|
||||||
pub fn get(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
pub fn post(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
pub fn delete(placeholder: String) -> String {
|
|
||||||
format!("ERROR: Not implemented yet, {}", placeholder)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user