mirror of
https://github.com/n08i40k/schedule-parser-rusted.git
synced 2025-12-06 09:47:50 +03:00
0.8.0
Реализованы все требуемые эндпоинты schedule. Улучшена документация.
This commit is contained in:
31
src/main.rs
31
src/main.rs
@@ -1,13 +1,19 @@
|
||||
use crate::app_state::{app_state, AppState};
|
||||
use crate::middlewares::authorization::Authorization;
|
||||
use crate::app_state::{AppState, app_state};
|
||||
use crate::middlewares::authorization::JWTAuthorization;
|
||||
use crate::routes::auth::sign_in::{sign_in_default, sign_in_vk};
|
||||
use crate::routes::auth::sign_up::{sign_up_default, sign_up_vk};
|
||||
use crate::routes::schedule::get_cache_status::get_cache_status;
|
||||
use crate::routes::schedule::get_group::get_group;
|
||||
use crate::routes::schedule::get_group_names::get_group_names;
|
||||
use crate::routes::schedule::get_schedule::get_schedule;
|
||||
use crate::routes::schedule::get_teacher::get_teacher;
|
||||
use crate::routes::schedule::get_teacher_names::get_teacher_names;
|
||||
use crate::routes::schedule::update_download_url::update_download_url;
|
||||
use crate::routes::users::me::me;
|
||||
use actix_web::{App, HttpServer};
|
||||
use dotenvy::dotenv;
|
||||
use utoipa_actix_web::AppExt;
|
||||
use utoipa_rapidoc::RapiDoc;
|
||||
use crate::routes::schedule::get_schedule::get_schedule;
|
||||
|
||||
mod app_state;
|
||||
|
||||
@@ -31,6 +37,8 @@ async fn main() {
|
||||
unsafe { std::env::set_var("RUST_LOG", "debug") };
|
||||
env_logger::init();
|
||||
|
||||
let app_state = app_state();
|
||||
|
||||
HttpServer::new(move || {
|
||||
let auth_scope = utoipa_actix_web::scope("/auth")
|
||||
.service(sign_in_default)
|
||||
@@ -39,12 +47,18 @@ async fn main() {
|
||||
.service(sign_up_vk);
|
||||
|
||||
let users_scope = utoipa_actix_web::scope("/users")
|
||||
.wrap(Authorization)
|
||||
.wrap(JWTAuthorization)
|
||||
.service(me);
|
||||
|
||||
|
||||
let schedule_scope = utoipa_actix_web::scope("/schedule")
|
||||
.wrap(Authorization)
|
||||
.service(get_schedule);
|
||||
.wrap(JWTAuthorization)
|
||||
.service(get_schedule)
|
||||
.service(update_download_url)
|
||||
.service(get_cache_status)
|
||||
.service(get_group)
|
||||
.service(get_group_names)
|
||||
.service(get_teacher)
|
||||
.service(get_teacher_names);
|
||||
|
||||
let api_scope = utoipa_actix_web::scope("/api/v1")
|
||||
.service(auth_scope)
|
||||
@@ -53,7 +67,7 @@ async fn main() {
|
||||
|
||||
let (app, api) = App::new()
|
||||
.into_utoipa_app()
|
||||
.app_data(app_state())
|
||||
.app_data(app_state.clone())
|
||||
.service(api_scope)
|
||||
.split_for_parts();
|
||||
|
||||
@@ -67,6 +81,7 @@ async fn main() {
|
||||
|
||||
app.service(rapidoc_service.custom_html(patched_rapidoc_html))
|
||||
})
|
||||
.workers(4)
|
||||
.bind(("0.0.0.0", 8080))
|
||||
.unwrap()
|
||||
.run()
|
||||
|
||||
Reference in New Issue
Block a user