mirror of
https://github.com/redlib-org/redlib.git
synced 2025-06-08 07:37:45 +00:00
Merge remote-tracking branch 'origin/pull/819'
This commit is contained in:
commit
90d1831352
8 changed files with 402 additions and 45 deletions
18
src/main.rs
18
src/main.rs
|
@ -6,6 +6,7 @@
|
|||
mod config;
|
||||
mod duplicates;
|
||||
mod instance_info;
|
||||
mod oauth;
|
||||
mod post;
|
||||
mod search;
|
||||
mod settings;
|
||||
|
@ -21,10 +22,13 @@ use hyper::{header::HeaderValue, Body, Request, Response};
|
|||
|
||||
mod client;
|
||||
use client::{canonical_path, proxy};
|
||||
use log::info;
|
||||
use once_cell::sync::Lazy;
|
||||
use server::RequestExt;
|
||||
use utils::{error, redirect, ThemeAssets};
|
||||
|
||||
use crate::client::OAUTH_CLIENT;
|
||||
|
||||
mod server;
|
||||
|
||||
// Create Services
|
||||
|
@ -108,6 +112,12 @@ async fn style() -> Result<Response<Body>, String> {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
// Load environment variables
|
||||
_ = dotenvy::dotenv();
|
||||
|
||||
// Initialize logger
|
||||
pretty_env_logger::init();
|
||||
|
||||
let matches = Command::new("Libreddit")
|
||||
.version(env!("CARGO_PKG_VERSION"))
|
||||
.about("Private front-end for Reddit written in Rust ")
|
||||
|
@ -162,10 +172,16 @@ async fn main() {
|
|||
|
||||
// Force evaluation of statics. In instance_info case, we need to evaluate
|
||||
// the timestamp so deploy date is accurate - in config case, we need to
|
||||
// evaluate the configuration to avoid paying penalty at first request.
|
||||
// evaluate the configuration to avoid paying penalty at first request -
|
||||
// in OAUTH case, we need to retrieve the token to avoid paying penalty
|
||||
// at first request
|
||||
|
||||
info!("Evaluating config.");
|
||||
Lazy::force(&config::CONFIG);
|
||||
info!("Evaluating instance info.");
|
||||
Lazy::force(&instance_info::INSTANCE_INFO);
|
||||
info!("Creating OAUTH client.");
|
||||
Lazy::force(&OAUTH_CLIENT);
|
||||
|
||||
// Define default headers (added to all responses)
|
||||
app.default_headers = headers! {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue