Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from brecert/project-consistency
- Loading branch information
Showing
8 changed files
with
87 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,29 @@ | ||
#[macro_use] | ||
extern crate lazy_static; | ||
|
||
use actix_web::middleware::Logger; | ||
use actix_web::{web, App, HttpServer}; | ||
use log::info; | ||
use util::variables::HOST; | ||
|
||
pub mod routes; | ||
pub mod structs; | ||
pub mod util; | ||
|
||
#[actix_web::main] | ||
async fn main() -> std::io::Result<()> { | ||
env_logger::init_from_env(env_logger::Env::default().filter_or("RUST_LOG", "info")); | ||
|
||
info!("Starting January server."); | ||
|
||
HttpServer::new(|| { | ||
App::new() | ||
.wrap(Logger::default()) | ||
.route("/", web::get().to(routes::info::get)) | ||
.route("/embed", web::get().to(routes::embed::get)) | ||
.route("/proxy", web::get().to(routes::proxy::get)) | ||
}) | ||
.bind(("0.0.0.0", 7000))? | ||
.bind(HOST.clone())? | ||
.run() | ||
.await | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use actix_web::web; | ||
use actix_web::Responder; | ||
use serde::Serialize; | ||
|
||
#[derive(Debug, Serialize)] | ||
pub struct Info { | ||
january: &'static str, | ||
} | ||
|
||
pub async fn get() -> impl Responder { | ||
web::Json(Info { | ||
january: env!("CARGO_PKG_VERSION"), | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod embed; | ||
pub mod proxy; | ||
pub mod info; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod request; | ||
pub mod result; | ||
pub mod variables; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::env; | ||
|
||
lazy_static! { | ||
// Application Settings | ||
pub static ref HOST: String = | ||
env::var("JANUARY_HOST").expect("Missing JANUARY_HOST environment variable."); | ||
} |