tsk-208: Moving config and endpoint code (#236)
* tsk-208: Moving config and endpoint code * tsk-208: Code formatting * tsk-208: Version bump * tsk-208: Accidentally changed port
This commit was merged in pull request #236.
This commit is contained in:
Generated
+1
-1
@@ -964,7 +964,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.18"
|
version = "0.3.19"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"axum",
|
"axum",
|
||||||
"axum-extra",
|
"axum-extra",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "icarus"
|
name = "icarus"
|
||||||
version = "0.3.18"
|
version = "0.3.19"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ pub mod queue;
|
|||||||
pub mod song;
|
pub mod song;
|
||||||
|
|
||||||
pub mod endpoints {
|
pub mod endpoints {
|
||||||
|
pub const ROOT: &str = "/";
|
||||||
|
|
||||||
pub const CREATESONG: &str = "/api/v2/song";
|
pub const CREATESONG: &str = "/api/v2/song";
|
||||||
pub const GETSONGS: &str = "/api/v2/song";
|
pub const GETSONGS: &str = "/api/v2/song";
|
||||||
pub const GETALLSONGS: &str = "/api/v2/song/all";
|
pub const GETALLSONGS: &str = "/api/v2/song/all";
|
||||||
@@ -17,3 +19,8 @@ pub mod endpoints {
|
|||||||
pub mod response {
|
pub mod response {
|
||||||
pub const SUCCESSFUL: &str = "SUCCESSFUL";
|
pub const SUCCESSFUL: &str = "SUCCESSFUL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Basic handler that responds with a static string
|
||||||
|
pub async fn root() -> &'static str {
|
||||||
|
"Hello, World!"
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
/// Full hosting address that the application will be broadcasting
|
||||||
|
pub fn get_full() -> String {
|
||||||
|
format!("{ADDRESS}:{PORT}")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const ADDRESS: &str = "0.0.0.0";
|
||||||
|
pub const PORT: &str = "8000";
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pub mod host;
|
||||||
+5
-24
@@ -1,5 +1,6 @@
|
|||||||
pub mod auth;
|
pub mod auth;
|
||||||
pub mod callers;
|
pub mod callers;
|
||||||
|
pub mod config;
|
||||||
pub mod repo;
|
pub mod repo;
|
||||||
|
|
||||||
pub mod db {
|
pub mod db {
|
||||||
@@ -41,7 +42,9 @@ async fn main() {
|
|||||||
// build our application with a route
|
// build our application with a route
|
||||||
let app = init::app().await;
|
let app = init::app().await;
|
||||||
|
|
||||||
let listener = tokio::net::TcpListener::bind(get_full()).await.unwrap();
|
let listener = tokio::net::TcpListener::bind(config::host::get_full())
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
axum::serve(listener, app).await.unwrap();
|
axum::serve(listener, app).await.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,7 +142,7 @@ pub mod init {
|
|||||||
|
|
||||||
pub async fn routes() -> axum::Router {
|
pub async fn routes() -> axum::Router {
|
||||||
axum::Router::new()
|
axum::Router::new()
|
||||||
.route(crate::ROOT, get(crate::root))
|
.route(crate::callers::endpoints::ROOT, get(crate::callers::root))
|
||||||
.route(
|
.route(
|
||||||
crate::callers::queue::endpoints::QUEUESONG,
|
crate::callers::queue::endpoints::QUEUESONG,
|
||||||
post(crate::callers::queue::song::endpoint::queue_song).route_layer(
|
post(crate::callers::queue::song::endpoint::queue_song).route_layer(
|
||||||
@@ -304,28 +307,6 @@ pub mod init {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move elsewhere
|
|
||||||
fn get_full() -> String {
|
|
||||||
get_address() + ":" + &get_port()
|
|
||||||
}
|
|
||||||
// TODO: Move elsewhere
|
|
||||||
fn get_address() -> String {
|
|
||||||
String::from("0.0.0.0")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move elsewhere
|
|
||||||
fn get_port() -> String {
|
|
||||||
String::from("8000")
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Move elsewhere
|
|
||||||
pub const ROOT: &str = "/";
|
|
||||||
// TODO: Move elsewhere
|
|
||||||
// basic handler that responds with a static string
|
|
||||||
pub async fn root() -> &'static str {
|
|
||||||
"Hello, World!"
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|||||||
Reference in New Issue
Block a user