Compare commits
No commits in common. "7aee0282b2271fbc9e313efc9b924246badd6875" and "ac7a753dd356d430a35eafcc711c2aea14a6b6cf" have entirely different histories.
7aee0282b2
...
ac7a753dd3
35
src/main.rs
35
src/main.rs
|
|
@ -7,7 +7,7 @@ use figment::{
|
|||
providers::{Env, Format, Yaml},
|
||||
Figment,
|
||||
};
|
||||
use rb::auth::JwtConf;
|
||||
use rb::{auth::JwtConf, guards};
|
||||
use rocket::{
|
||||
fairing::AdHoc,
|
||||
http::Status,
|
||||
|
|
@ -17,7 +17,8 @@ use rocket::{
|
|||
use rocket_sync_db_pools::database;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
pub mod v1;
|
||||
pub mod posts;
|
||||
pub mod sections;
|
||||
|
||||
#[database("postgres_rb")]
|
||||
pub struct RbDbConn(diesel::PgConnection);
|
||||
|
|
@ -48,6 +49,9 @@ pub struct RbConfig
|
|||
jwt: JwtConf,
|
||||
}
|
||||
|
||||
#[get("/test")]
|
||||
async fn test(_yeet: guards::Jwt) {}
|
||||
|
||||
#[launch]
|
||||
fn rocket() -> _
|
||||
{
|
||||
|
|
@ -65,25 +69,26 @@ fn rocket() -> _
|
|||
// .attach(AdHoc::config::<JwtConf>())
|
||||
.register("/", catchers![default_catcher])
|
||||
.mount(
|
||||
"/v1/sections",
|
||||
"/sections",
|
||||
routes![
|
||||
v1::sections::get,
|
||||
v1::sections::create,
|
||||
v1::sections::find,
|
||||
v1::sections::patch,
|
||||
v1::sections::delete
|
||||
sections::get,
|
||||
sections::create,
|
||||
sections::find,
|
||||
sections::patch,
|
||||
sections::delete
|
||||
],
|
||||
)
|
||||
.mount(
|
||||
"/v1/posts",
|
||||
"/posts",
|
||||
routes![
|
||||
v1::posts::get,
|
||||
v1::posts::create,
|
||||
v1::posts::find,
|
||||
v1::posts::patch,
|
||||
v1::posts::delete
|
||||
posts::get,
|
||||
posts::create,
|
||||
posts::find,
|
||||
posts::patch,
|
||||
posts::delete
|
||||
],
|
||||
);
|
||||
)
|
||||
.mount("/", routes![test]);
|
||||
|
||||
let new_figment = rocket.figment();
|
||||
let jwt_conf: JwtConf = new_figment.extract_inner("jwt").expect("jwt config");
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
pub mod posts;
|
||||
pub mod sections;
|
||||
7
test.py
7
test.py
|
|
@ -1,7 +1,6 @@
|
|||
import requests
|
||||
|
||||
# Token specifically used for testing. It's signed with secret "secret" & expires in 2034 or something
|
||||
token = "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVjMjM2OTI0NjY4ZDQzZWFiNGNmNDczYjk1YWZiNzgzIiwidXNlcm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlLCJleHAiOjE1MTYyMzkwMjIwfQ.if939L9le8LP-dtXnQs-mHPkb-VieRAvAfSu20755jY"
|
||||
token = "eyJhbGciOiJIUzI1NiJ9.eyJpZCI6IjVjMjM2OTI0NjY4ZDQzZWFiNGNmNDczYjk1YWZiNzgzIiwidXNlcm5hbWUiOiJKb2huIERvZSIsImFkbWluIjp0cnVlLCJleHAiOjE1MTYyMzkwMjIwfQ.3AzUBe08lcnC3fUIMqPZ8kG51PNPS4MAMpoh_v5HSKM"
|
||||
|
||||
headers = {
|
||||
"Authorization": f"Bearer {token}"
|
||||
|
|
@ -12,8 +11,6 @@ data = {
|
|||
"shortname": "short",
|
||||
}
|
||||
|
||||
r = requests.post("http://localhost:8000/sections", headers=headers, json=data)
|
||||
r = requests.get("http://localhost:8000/test", headers=headers)
|
||||
print(r.content)
|
||||
print(r.status_code)
|
||||
r = requests.get("http://localhost:8000/sections?offset=0&limit=100")
|
||||
print(r.json())
|
||||
|
|
|
|||
Reference in New Issue