web server functionality
This commit is contained in:
parent
f2044d356a
commit
b273952d7a
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -1,3 +1,3 @@
|
||||
{
|
||||
"cSpell.words": ["clippy", "colog"]
|
||||
"cSpell.words": ["clippy", "colog", "smol"]
|
||||
}
|
||||
|
2348
Cargo.lock
generated
2348
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "spoon-blog"
|
||||
version = "0.2.0"
|
||||
version = "0.3.0"
|
||||
edition = "2024"
|
||||
description = "Server for my blog"
|
||||
repository = "https://repos.slottedspoon.dev/nicola/spoon-blog"
|
||||
@ -12,4 +12,9 @@ pedantic = "warn"
|
||||
|
||||
[dependencies]
|
||||
colog = "1.3.0"
|
||||
env_logger = "0.11.8"
|
||||
log = "0.4.27"
|
||||
macro_rules_attribute = "0.2.0"
|
||||
smol = "2.0.2"
|
||||
smol-macros = "0.1.1"
|
||||
tide = "0.16.0"
|
||||
|
23
src/main.rs
23
src/main.rs
@ -6,12 +6,23 @@
|
||||
* Copyright 2025 Nicola Clark
|
||||
*/
|
||||
|
||||
use std::env;
|
||||
use std::{env, sync::LazyLock};
|
||||
|
||||
use env_logger::Logger;
|
||||
use log::LevelFilter;
|
||||
use macro_rules_attribute::apply;
|
||||
use smol_macros::main;
|
||||
|
||||
static LOGGER: LazyLock<Logger> = LazyLock::new(|| {
|
||||
colog::default_builder()
|
||||
.filter_module("tide", LevelFilter::Warn)
|
||||
.build()
|
||||
});
|
||||
|
||||
#[apply(main!)]
|
||||
async fn main() {
|
||||
log::set_logger(&*LOGGER).unwrap();
|
||||
|
||||
fn main() {
|
||||
colog::init();
|
||||
if let Ok(b_log_level) = env::var("B_LOG_LEVEL") {
|
||||
log::set_max_level(match b_log_level.as_str() {
|
||||
"off" => LevelFilter::Off,
|
||||
@ -26,4 +37,10 @@ fn main() {
|
||||
}
|
||||
|
||||
log::info!("spoon-blog v{}", env!("CARGO_PKG_VERSION"));
|
||||
|
||||
let mut app = tide::new();
|
||||
app.at("/").get(async |_| Ok("howdy y'all!!!"));
|
||||
if let Err(tide_err) = app.listen("0.0.0.0:8080").await {
|
||||
log::error!("issue serving HTTP: {tide_err}");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user