Add swagger-ui
This commit is contained in:
parent
51c42d5202
commit
e950a33e98
9 changed files with 263 additions and 44 deletions
emgauwa-core/src/handlers/v1
|
@ -9,7 +9,7 @@ use sqlx::{Pool, Sqlite};
|
|||
use crate::app_state;
|
||||
use crate::app_state::AppState;
|
||||
|
||||
#[get("/api/v1/controllers")]
|
||||
#[get("/controllers")]
|
||||
pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, EmgauwaError> {
|
||||
let mut pool_conn = pool.acquire().await?;
|
||||
|
||||
|
@ -20,7 +20,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, Emgauw
|
|||
Ok(HttpResponse::Ok().json(controllers))
|
||||
}
|
||||
|
||||
#[get("/api/v1/controllers/{controller_id}")]
|
||||
#[get("/controllers/{controller_id}")]
|
||||
pub async fn show(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -38,7 +38,7 @@ pub async fn show(
|
|||
Ok(HttpResponse::Ok().json(return_controller))
|
||||
}
|
||||
|
||||
#[put("/api/v1/controllers/{controller_id}")]
|
||||
#[put("/controllers/{controller_id}")]
|
||||
pub async fn update(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
app_state: web::Data<Addr<AppState>>,
|
||||
|
@ -70,7 +70,7 @@ pub async fn update(
|
|||
Ok(HttpResponse::Ok().json(return_controller))
|
||||
}
|
||||
|
||||
#[delete("/api/v1/controllers/{controller_id}")]
|
||||
#[delete("/controllers/{controller_id}")]
|
||||
pub async fn delete(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
app_state: web::Data<Addr<AppState>>,
|
||||
|
|
|
@ -10,7 +10,7 @@ use sqlx::{Pool, Sqlite};
|
|||
use crate::app_state;
|
||||
use crate::app_state::AppState;
|
||||
|
||||
#[get("/api/v1/relays")]
|
||||
#[get("/relays")]
|
||||
pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, EmgauwaError> {
|
||||
let mut pool_conn = pool.acquire().await?;
|
||||
|
||||
|
@ -21,7 +21,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, Emgauw
|
|||
Ok(HttpResponse::Ok().json(relays))
|
||||
}
|
||||
|
||||
#[get("/api/v1/relays/tag/{tag}")]
|
||||
#[get("/relays/tag/{tag}")]
|
||||
pub async fn tagged(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -39,7 +39,7 @@ pub async fn tagged(
|
|||
Ok(HttpResponse::Ok().json(relays))
|
||||
}
|
||||
|
||||
#[get("/api/v1/controllers/{controller_id}/relays")]
|
||||
#[get("/controllers/{controller_id}/relays")]
|
||||
pub async fn index_for_controller(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -59,7 +59,7 @@ pub async fn index_for_controller(
|
|||
Ok(HttpResponse::Ok().json(relays))
|
||||
}
|
||||
|
||||
#[get("/api/v1/controllers/{controller_id}/relays/{relay_num}")]
|
||||
#[get("/controllers/{controller_id}/relays/{relay_num}")]
|
||||
pub async fn show_for_controller(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String, i64)>,
|
||||
|
@ -81,7 +81,7 @@ pub async fn show_for_controller(
|
|||
Ok(HttpResponse::Ok().json(return_relay))
|
||||
}
|
||||
|
||||
#[put("/api/v1/controllers/{controller_id}/relays/{relay_num}")]
|
||||
#[put("/controllers/{controller_id}/relays/{relay_num}")]
|
||||
pub async fn update_for_controller(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
app_state: web::Data<Addr<AppState>>,
|
||||
|
|
|
@ -6,7 +6,7 @@ use emgauwa_lib::types::{RequestCreateSchedule, RequestUpdateSchedule, ScheduleU
|
|||
use sqlx::pool::PoolConnection;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
||||
#[get("/api/v1/schedules")]
|
||||
#[get("/schedules")]
|
||||
pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, EmgauwaError> {
|
||||
let mut pool_conn = pool.acquire().await?;
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, Emgauw
|
|||
Ok(HttpResponse::Ok().json(schedules))
|
||||
}
|
||||
|
||||
#[get("/api/v1/schedules/tag/{tag}")]
|
||||
#[get("/schedules/tag/{tag}")]
|
||||
pub async fn tagged(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -34,7 +34,7 @@ pub async fn tagged(
|
|||
Ok(HttpResponse::Ok().json(schedules))
|
||||
}
|
||||
|
||||
#[get("/api/v1/schedules/{schedule_id}")]
|
||||
#[get("/schedules/{schedule_id}")]
|
||||
pub async fn show(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -52,7 +52,7 @@ pub async fn show(
|
|||
Ok(HttpResponse::Ok().json(return_schedule))
|
||||
}
|
||||
|
||||
#[post("/api/v1/schedules")]
|
||||
#[post("/schedules")]
|
||||
pub async fn add(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
data: web::Json<RequestCreateSchedule>,
|
||||
|
@ -96,7 +96,7 @@ async fn add_list_single(
|
|||
Ok(new_schedule)
|
||||
}
|
||||
|
||||
#[post("/api/v1/schedules/list")]
|
||||
#[post("/schedules/list")]
|
||||
pub async fn add_list(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
data: web::Json<Vec<RequestCreateSchedule>>,
|
||||
|
@ -113,7 +113,7 @@ pub async fn add_list(
|
|||
Ok(HttpResponse::Created().json(schedules))
|
||||
}
|
||||
|
||||
#[put("/api/v1/schedules/{schedule_id}")]
|
||||
#[put("/schedules/{schedule_id}")]
|
||||
pub async fn update(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -148,7 +148,7 @@ pub async fn update(
|
|||
Ok(HttpResponse::Ok().json(return_schedule))
|
||||
}
|
||||
|
||||
#[delete("/api/v1/schedules/{schedule_id}")]
|
||||
#[delete("/schedules/{schedule_id}")]
|
||||
pub async fn delete(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
|
|
@ -5,7 +5,7 @@ use emgauwa_lib::models::{FromDbModel, Tag};
|
|||
use emgauwa_lib::types::RequestCreateTag;
|
||||
use sqlx::{Pool, Sqlite};
|
||||
|
||||
#[get("/api/v1/tags")]
|
||||
#[get("/tags")]
|
||||
pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, EmgauwaError> {
|
||||
let mut pool_conn = pool.acquire().await?;
|
||||
|
||||
|
@ -16,7 +16,7 @@ pub async fn index(pool: web::Data<Pool<Sqlite>>) -> Result<HttpResponse, Emgauw
|
|||
Ok(HttpResponse::Ok().json(tags))
|
||||
}
|
||||
|
||||
#[get("/api/v1/tags/{tag_name}")]
|
||||
#[get("/tags/{tag_name}")]
|
||||
pub async fn show(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -33,7 +33,7 @@ pub async fn show(
|
|||
Ok(HttpResponse::Ok().json(return_tag))
|
||||
}
|
||||
|
||||
#[delete("/api/v1/tags/{tag_name}")]
|
||||
#[delete("/tags/{tag_name}")]
|
||||
pub async fn delete(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
path: web::Path<(String,)>,
|
||||
|
@ -46,7 +46,7 @@ pub async fn delete(
|
|||
Ok(HttpResponse::Ok().json("tag got deleted"))
|
||||
}
|
||||
|
||||
#[post("/api/v1/tags")]
|
||||
#[post("/tags")]
|
||||
pub async fn add(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
data: web::Json<RequestCreateTag>,
|
||||
|
|
|
@ -11,7 +11,7 @@ use crate::handlers::v1::ws::controllers::ControllerWs;
|
|||
|
||||
pub mod controllers;
|
||||
|
||||
#[get("/api/v1/ws/controllers")]
|
||||
#[get("/ws/controllers")]
|
||||
pub async fn ws_controllers(
|
||||
pool: web::Data<Pool<Sqlite>>,
|
||||
app_state: web::Data<Addr<AppState>>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue