feature: Raw endpoint is back!

This commit is contained in:
Dominic Harris 2022-03-24 09:19:52 -04:00
parent fb4b814e0a
commit 6bc1e8c421
No known key found for this signature in database
GPG Key ID: 93CCF85F3E2A4F65
4 changed files with 1831 additions and 3101 deletions

View File

@ -14,7 +14,7 @@ use config::Config;
use sqlx::{postgres::PgPoolOptions, PgPool};
use crate::routes::{get_paste, get_stats, get_total_pastes_badge, get_version_badge, new_paste};
use crate::routes::{get_paste, get_stats, get_total_pastes_badge, get_version_badge, new_paste, get_raw_paste};
#[derive(Clone)]
pub struct AppState {
@ -62,7 +62,8 @@ async fn main() -> io::Result<()> {
web::scope("/p")
.wrap(Governor::new(&paste_governor))
.service(get_paste)
.service(new_paste), // .service(get_raw_paste),
.service(new_paste)
.service(get_raw_paste),
)
.service(
web::scope("/b")

View File

@ -75,7 +75,6 @@ pub async fn get_paste(state: web::Data<AppState>, id: web::Path<String>) -> imp
}
}
// TODO: Fix major vuln
#[get("/r/{id}")]
pub async fn get_raw_paste(state: web::Data<AppState>, id: web::Path<String>) -> impl Responder {
let id = id.into_inner();
@ -94,7 +93,7 @@ pub async fn get_raw_paste(state: web::Data<AppState>, id: web::Path<String>) ->
.execute(&state.pool)
.await;
HttpResponse::Ok().body(p.content)
HttpResponse::Ok().content_type("text/plain").body(p.content)
}
Err(e) => match e {
sqlx::Error::RowNotFound => {

View File

@ -9,6 +9,9 @@
"build": "parcel build index.pug --public-url /"
},
"devDependencies": {
"@parcel/compressor-brotli": "^2.4.0",
"@parcel/compressor-gzip": "^2.4.0",
"@parcel/transformer-sass": "2.4.0",
"@types/core-js": "^2.5.5",
"@types/node": "^17.0.21"
},

File diff suppressed because it is too large Load Diff