mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 16:26:28 +00:00
update actix to version 4
This commit is contained in:
parent
1adf87b884
commit
229c8d8368
1181
backend/Cargo.lock
generated
1181
backend/Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -11,9 +11,9 @@ path = "src/main.rs"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix-web = "3"
|
actix-web = "4"
|
||||||
actix-files = "0.5"
|
actix-files = "0.6"
|
||||||
serde = "1"
|
serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
lazy_static = "1"
|
lazy_static = "1"
|
||||||
ring = "0.16"
|
ring = "0.16"
|
||||||
|
25
backend/src/api.rs
Normal file
25
backend/src/api.rs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
use actix_web::{get, web, HttpResponse, Responder};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::note;
|
||||||
|
use crate::size::LIMIT;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct Status {
|
||||||
|
version: String,
|
||||||
|
max_size: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[get("/status")]
|
||||||
|
async fn status() -> impl Responder {
|
||||||
|
return HttpResponse::Ok().json(Status {
|
||||||
|
version: option_env!("CARGO_PKG_VERSION")
|
||||||
|
.unwrap_or("Unknown")
|
||||||
|
.to_string(),
|
||||||
|
max_size: *LIMIT,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||||
|
cfg.service(web::scope("/api").service(note::service()).service(status));
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
use actix_files::{Files, NamedFile};
|
use actix_files::Files;
|
||||||
use actix_web::{web, Responder};
|
use actix_web::web;
|
||||||
|
|
||||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||||
cfg.service(Files::new("/", "./frontend/build").index_file("index.html"));
|
cfg.service(
|
||||||
}
|
Files::new("/", "./frontend/build")
|
||||||
|
.index_file("index.html")
|
||||||
pub async fn fallback_fn() -> impl Responder {
|
.use_etag(true),
|
||||||
NamedFile::open("./frontend/build/index.html")
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
use actix_web::{middleware, web, App, HttpServer};
|
use actix_web::{middleware, App, HttpServer};
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
|
|
||||||
|
mod api;
|
||||||
mod client;
|
mod client;
|
||||||
mod note;
|
mod note;
|
||||||
mod size;
|
mod size;
|
||||||
@ -17,9 +18,8 @@ async fn main() -> std::io::Result<()> {
|
|||||||
.wrap(middleware::Compress::default())
|
.wrap(middleware::Compress::default())
|
||||||
.wrap(middleware::DefaultHeaders::default())
|
.wrap(middleware::DefaultHeaders::default())
|
||||||
.configure(size::init)
|
.configure(size::init)
|
||||||
.configure(note::init)
|
.configure(api::init)
|
||||||
.configure(client::init)
|
.configure(client::init)
|
||||||
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
|
||||||
})
|
})
|
||||||
.bind("0.0.0.0:5000")?
|
.bind("0.0.0.0:5000")?
|
||||||
.run()
|
.run()
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
use actix_web::{delete, get, post, web, HttpResponse, Responder};
|
use actix_web::{delete, get, post, web, HttpResponse, Responder, Scope};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::time::SystemTime;
|
use std::time::SystemTime;
|
||||||
|
|
||||||
@ -122,16 +122,9 @@ async fn status() -> impl Responder {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
pub fn service() -> Scope {
|
||||||
cfg.service(
|
web::scope("/notes")
|
||||||
web::scope("/api")
|
.service(one)
|
||||||
.service(
|
.service(create)
|
||||||
web::scope("/notes")
|
.service(delete)
|
||||||
.service(one)
|
|
||||||
.service(create)
|
|
||||||
.service(delete)
|
|
||||||
.service(status),
|
|
||||||
)
|
|
||||||
.service(status),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,9 @@ lazy_static! {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||||
println!("Limit: {}", *LIMIT);
|
|
||||||
let json = web::JsonConfig::default().limit(*LIMIT);
|
let json = web::JsonConfig::default().limit(*LIMIT);
|
||||||
let plain = web::PayloadConfig::default()
|
let plain = web::PayloadConfig::default()
|
||||||
.limit(*LIMIT)
|
.limit(*LIMIT)
|
||||||
.mimetype(mime::STAR_STAR);
|
.mimetype(mime::STAR_STAR);
|
||||||
cfg.data(json);
|
cfg.app_data(json).app_data(plain);
|
||||||
cfg.data(plain);
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user