Made some formatting changes.
This commit is contained in:
21
.editorconfig
Normal file
21
.editorconfig
Normal file
@@ -0,0 +1,21 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
root = true
|
||||
[*]
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
[*.rs]
|
||||
max_line_length = 100
|
||||
[*.md]
|
||||
# double whitespace at end of line
|
||||
# denotes a line break in Markdown
|
||||
trim_trailing_whitespace = false
|
||||
[*.yml]
|
||||
indent_size = 2
|
||||
[Makefile]
|
||||
indent_style = tab
|
||||
7
rustfmt.toml
Normal file
7
rustfmt.toml
Normal file
@@ -0,0 +1,7 @@
|
||||
edition = "2024"
|
||||
style_edition = "2024"
|
||||
comment_width = 100
|
||||
format_code_in_doc_comments = true
|
||||
imports_granularity = "Crate"
|
||||
imports_layout = "Vertical"
|
||||
wrap_comments = true
|
||||
@@ -1,7 +1,10 @@
|
||||
// Just a way to unify error handling. Can translate eyre Reports into
|
||||
// axum responses.
|
||||
|
||||
use axum::{http::StatusCode, response::IntoResponse};
|
||||
use axum::{
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
};
|
||||
use color_eyre::eyre::Report;
|
||||
use std::fmt::Display;
|
||||
|
||||
|
||||
52
src/main.rs
52
src/main.rs
@@ -1,23 +1,50 @@
|
||||
// TODO: Add general description of the workings.
|
||||
// TODO: Add ability to run a temporary pastebin
|
||||
|
||||
use crate::error::GBError;
|
||||
use axum::{
|
||||
BoxError, Router,
|
||||
BoxError,
|
||||
Router,
|
||||
error_handling::HandleErrorLayer,
|
||||
extract::{DefaultBodyLimit, Multipart, Path, State},
|
||||
extract::{
|
||||
DefaultBodyLimit,
|
||||
Multipart,
|
||||
Path,
|
||||
State,
|
||||
},
|
||||
http::StatusCode,
|
||||
response::{Html, IntoResponse, Response},
|
||||
routing::{get, post},
|
||||
response::{
|
||||
Html,
|
||||
IntoResponse,
|
||||
Response,
|
||||
},
|
||||
routing::{
|
||||
get,
|
||||
post,
|
||||
},
|
||||
};
|
||||
use clap::Parser;
|
||||
use crate::error::GBError;
|
||||
use nanoid::nanoid;
|
||||
use std::{path::PathBuf, time::Duration};
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
time::Duration,
|
||||
};
|
||||
use store::Store;
|
||||
use tokio::fs;
|
||||
use tower::{ServiceBuilder, buffer::BufferLayer, limit::rate::RateLimitLayer};
|
||||
use tower_http::{compression::CompressionLayer, limit::RequestBodyLimitLayer, trace::TraceLayer};
|
||||
use tracing::{Level, event};
|
||||
use tower::{
|
||||
ServiceBuilder,
|
||||
buffer::BufferLayer,
|
||||
limit::rate::RateLimitLayer,
|
||||
};
|
||||
use tower_http::{
|
||||
compression::CompressionLayer,
|
||||
limit::RequestBodyLimitLayer,
|
||||
trace::TraceLayer,
|
||||
};
|
||||
use tracing::{
|
||||
Level,
|
||||
event,
|
||||
};
|
||||
|
||||
mod error;
|
||||
mod store;
|
||||
@@ -107,8 +134,11 @@ async fn paste_request(State(state): State<Store>, Path(paste_id): Path<String>)
|
||||
// RUST_LOG environment variable.
|
||||
fn install_tracing() {
|
||||
use tracing_error::ErrorLayer;
|
||||
use tracing_subscriber::prelude::*;
|
||||
use tracing_subscriber::{EnvFilter, fmt};
|
||||
use tracing_subscriber::{
|
||||
EnvFilter,
|
||||
fmt,
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
let fmt_layer = fmt::layer().with_target(false);
|
||||
let filter_layer = EnvFilter::try_from_default_env()
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
use color_eyre::Result;
|
||||
use rocksdb::DB;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::sync::Arc;
|
||||
use std::{
|
||||
path::{
|
||||
Path,
|
||||
PathBuf,
|
||||
},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Store {
|
||||
|
||||
Reference in New Issue
Block a user