mirror of https://github.com/zer0bin-dev/zer0bin
✨ feature: Raw endpoint is back!
This commit is contained in:
parent
fb4b814e0a
commit
6bc1e8c421
|
@ -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")
|
||||
|
|
|
@ -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 => {
|
||||
|
|
|
@ -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"
|
||||
},
|
||||
|
|
4921
frontend/yarn.lock
4921
frontend/yarn.lock
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue