tangled
alpha
login
or
join now
slipnote.app
/
slipnote
3
fork
atom
Built for people who think better out loud.
3
fork
atom
overview
issues
pulls
pipelines
backend: Refactor routes
isaaccorbrey.com
4 weeks ago
f51c28c5
ec29ef33
verified
This commit was signed with the committer's
known signature
.
isaaccorbrey.com
SSH Key Fingerprint:
SHA256:mwogCTZEXIXrYk4l7PaavTNPxe1Xqjf5jMIBe0LvAHU=
+23
-15
3 changed files
expand all
collapse all
unified
split
backend
src
main.rs
routers
health.rs
mod.rs
+5
-15
backend/src/main.rs
···
1
1
-
use axum::{Router, routing::get};
2
1
use tokio::net::TcpListener;
2
2
+
3
3
+
mod routers;
3
4
4
5
#[tokio::main]
5
6
async fn main() {
6
6
-
let app = Router::new()
7
7
-
.route("/", get(root))
8
8
-
.route("/health", get(health));
9
9
-
10
10
-
let listener = TcpListener::bind("0.0.0.0:3000")
7
7
+
let app = routers::router();
8
8
+
let listener = TcpListener::bind("0.0.0.0:3001")
11
9
.await
12
12
-
.expect("failed to bind to 0.0.0.0:3000");
10
10
+
.expect("failed to bind to 0.0.0.0:3001");
13
11
14
12
axum::serve(listener, app)
15
13
.await
16
14
.expect("axum server failed");
17
15
}
18
18
-
19
19
-
async fn root() -> &'static str {
20
20
-
"slipnote backend"
21
21
-
}
22
22
-
23
23
-
async fn health() -> &'static str {
24
24
-
"ok"
25
25
-
}
+10
backend/src/routers/health.rs
···
1
1
+
use axum::{Router, routing::get};
2
2
+
3
3
+
pub fn router() -> Router {
4
4
+
Router::new()
5
5
+
.route("/health", get(health))
6
6
+
}
7
7
+
8
8
+
async fn health() -> &'static str {
9
9
+
"ok"
10
10
+
}
+8
backend/src/routers/mod.rs
···
1
1
+
use axum::Router;
2
2
+
3
3
+
mod health;
4
4
+
5
5
+
pub fn router() -> Router {
6
6
+
Router::new()
7
7
+
.merge(health::router())
8
8
+
}