asghfuiasgkuagdsisgbkvusyudkfyugfiykgigkufgugfuyrogeig
This commit is contained in:
parent
40da63bc8e
commit
dd9cf9b16c
|
@ -3,18 +3,12 @@ pub mod events;
|
|||
|
||||
use std::{borrow::BorrowMut, sync::Mutex};
|
||||
|
||||
use actix_web::{http::header, web::{self, Bytes, Data}, HttpRequest, HttpResponse, Responder, Result, Scope};
|
||||
use actix_web::{http::header, post, web::{self, Bytes, Data}, HttpRequest, HttpResponse, Responder, Result, Scope};
|
||||
|
||||
use crate::database::{models, Database};
|
||||
|
||||
pub async fn handler(req: HttpRequest, body: Bytes, db: Data<Mutex<Database>>) -> Result<impl Responder> {
|
||||
let Some(auth) = req.headers().get(header::AUTHORIZATION) else {
|
||||
return Ok(HttpResponse::Unauthorized());
|
||||
};
|
||||
pub async fn handler(req: HttpRequest, token: web::Path<String>, body: Bytes, db: Data<Mutex<Database>>) -> Result<impl Responder> {
|
||||
|
||||
let Ok(token) = auth.to_str() else {
|
||||
return Ok(HttpResponse::Unauthorized());
|
||||
};
|
||||
|
||||
let token = models::tokens::Token::get_by_token(
|
||||
db.lock().unwrap().borrow_mut(),
|
||||
|
|
|
@ -7,5 +7,5 @@ pub fn get_scope() -> Scope {
|
|||
Scope::new("/wh")
|
||||
.route("/", web::get().to(HttpResponse::Ok))
|
||||
.route("/github", web::get().to(HttpResponse::Ok))
|
||||
.route("/github", web::post().to(github::handler))
|
||||
.route("/github/{token}", web::post().to(github::handler))
|
||||
}
|
Loading…
Reference in New Issue
Block a user