mirror of
https://github.com/cupcakearmy/cryptgeon.git
synced 2024-12-22 00:06: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
|
||||
|
||||
[dependencies]
|
||||
actix-web = "3"
|
||||
actix-files = "0.5"
|
||||
serde = "1"
|
||||
actix-web = "4"
|
||||
actix-files = "0.6"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
lazy_static = "1"
|
||||
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_web::{web, Responder};
|
||||
use actix_files::Files;
|
||||
use actix_web::web;
|
||||
|
||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(Files::new("/", "./frontend/build").index_file("index.html"));
|
||||
}
|
||||
|
||||
pub async fn fallback_fn() -> impl Responder {
|
||||
NamedFile::open("./frontend/build/index.html")
|
||||
cfg.service(
|
||||
Files::new("/", "./frontend/build")
|
||||
.index_file("index.html")
|
||||
.use_etag(true),
|
||||
);
|
||||
}
|
||||
|
@ -1,9 +1,10 @@
|
||||
use actix_web::{middleware, web, App, HttpServer};
|
||||
use actix_web::{middleware, App, HttpServer};
|
||||
use dotenv::dotenv;
|
||||
|
||||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
|
||||
mod api;
|
||||
mod client;
|
||||
mod note;
|
||||
mod size;
|
||||
@ -17,9 +18,8 @@ async fn main() -> std::io::Result<()> {
|
||||
.wrap(middleware::Compress::default())
|
||||
.wrap(middleware::DefaultHeaders::default())
|
||||
.configure(size::init)
|
||||
.configure(note::init)
|
||||
.configure(api::init)
|
||||
.configure(client::init)
|
||||
.default_service(web::resource("").route(web::get().to(client::fallback_fn)))
|
||||
})
|
||||
.bind("0.0.0.0:5000")?
|
||||
.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 std::time::SystemTime;
|
||||
|
||||
@ -122,16 +122,9 @@ async fn status() -> impl Responder {
|
||||
});
|
||||
}
|
||||
|
||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||
cfg.service(
|
||||
web::scope("/api")
|
||||
.service(
|
||||
web::scope("/notes")
|
||||
.service(one)
|
||||
.service(create)
|
||||
.service(delete)
|
||||
.service(status),
|
||||
)
|
||||
.service(status),
|
||||
);
|
||||
pub fn service() -> Scope {
|
||||
web::scope("/notes")
|
||||
.service(one)
|
||||
.service(create)
|
||||
.service(delete)
|
||||
}
|
||||
|
@ -10,11 +10,9 @@ lazy_static! {
|
||||
}
|
||||
|
||||
pub fn init(cfg: &mut web::ServiceConfig) {
|
||||
println!("Limit: {}", *LIMIT);
|
||||
let json = web::JsonConfig::default().limit(*LIMIT);
|
||||
let plain = web::PayloadConfig::default()
|
||||
.limit(*LIMIT)
|
||||
.mimetype(mime::STAR_STAR);
|
||||
cfg.data(json);
|
||||
cfg.data(plain);
|
||||
cfg.app_data(json).app_data(plain);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user