Skip to content

Commit 5c72ae9

Browse files
authored
Update main.rs, remove tmp code
1 parent ba82983 commit 5c72ae9

File tree

1 file changed

+0
-70
lines changed

1 file changed

+0
-70
lines changed

src/main.rs

-70
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ mod constants;
2929
mod entities;
3030
mod log;
3131
mod osrm;
32-
mod backend;
3332

3433
#[derive(Clone)]
3534
struct AppState {
@@ -51,72 +50,6 @@ impl AppState {
5150
}
5251
}
5352

54-
async fn calendar(
55-
_uri: Uri,
56-
State(s): State<AppState>,
57-
) -> Result<Html<String>, StatusCode> {
58-
s.render("calendar.html", &Context::new())
59-
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
60-
.map(|x| Html(x))
61-
}
62-
63-
async fn register(
64-
_uri: Uri,
65-
State(s): State<AppState>,
66-
) -> Result<Html<String>, StatusCode> {
67-
s.render("register.html", &Context::new())
68-
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)
69-
.map(|x| Html(x))
70-
}
71-
72-
async fn users(State(s): State<AppState>) -> Result<Html<String>, StatusCode> {
73-
let result = User::insert(user::ActiveModel {
74-
display_name: ActiveValue::Set("Test".to_string()),
75-
id: ActiveValue::NotSet,
76-
is_driver: ActiveValue::Set(true),
77-
is_disponent: ActiveValue::Set(false),
78-
is_admin: ActiveValue::Set(true),
79-
email: ActiveValue::Set("".to_string()),
80-
password: ActiveValue::Set(Some("".to_string())),
81-
salt: ActiveValue::Set("".to_string()),
82-
o_auth_id: ActiveValue::Set(Some("".to_string())),
83-
o_auth_provider: ActiveValue::Set(Some("".to_string())),
84-
active: ActiveValue::NotSet,
85-
company: ActiveValue::NotSet,
86-
})
87-
.exec(s.db())
88-
.await;
89-
90-
match result {
91-
Ok(_) => info!("User added"),
92-
Err(e) => error!("Error adding user: {e:?}"),
93-
}
94-
95-
let username = User::find_by_id(1)
96-
.one(s.db())
97-
.await
98-
.map_err(|e| {
99-
error!("Database error: {e:?}");
100-
StatusCode::INTERNAL_SERVER_ERROR
101-
})?
102-
.ok_or(StatusCode::NOT_FOUND)?
103-
.display_name
104-
.clone();
105-
let response = s
106-
.render(
107-
"user.html",
108-
&Context::from_serialize(json!({"user": username})).map_err(|e| {
109-
error!("Serialize error: {e:?}");
110-
StatusCode::INTERNAL_SERVER_ERROR
111-
})?,
112-
)
113-
.map_err(|e| {
114-
error!("Render error: {e:?}");
115-
StatusCode::INTERNAL_SERVER_ERROR
116-
})?;
117-
Ok(Html(response))
118-
}
119-
12053
#[tokio::main]
12154
async fn main() -> Result<(), Box<dyn std::error::Error>> {
12255
setup_logging()?;
@@ -162,9 +95,6 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
16295
};
16396

16497
let app = Router::new();
165-
let app = app.route("/calendar", get(calendar).with_state(s.clone()));
166-
let app = app.route("/register", get(register).with_state(s.clone()));
167-
let app = app.route("/users", get(users).with_state(s.clone()));
16898
let app = app.route_service("/output.css", ServeFile::new("output.css"));
16999
let app = app.layer(livereload);
170100
let app = app.layer(CompressionLayer::new());

0 commit comments

Comments
 (0)