+ Skeleton code for the /video-api
With this we can start work on the api code itself which at this point should be fill in as we go
This commit is contained in:
parent
8a3b85351e
commit
3623a8236f
@ -1,4 +1,36 @@
|
||||
#[get("/<video_id>")]
|
||||
fn video_page() -> String {
|
||||
format!("TODO")
|
||||
use rocket_contrib::json::Json;
|
||||
use rocket_contrib::json::JsonValue;
|
||||
use dblib::{DB, request::ApiKey};
|
||||
use dblib::KeyStore;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct GenericResponse<'m> {
|
||||
msg: Option<&'m str>,
|
||||
err: bool
|
||||
}
|
||||
|
||||
#[get("/by-id")]
|
||||
pub fn get_vid_by_id(id: String) -> JsonValue {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[get("/by-name")]
|
||||
pub fn get_vid_by_name(name: String) -> JsonValue {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[update("/description?<id>&<new>")]
|
||||
pub fn update_description<'m>(key: ApiKey, id: String, desc: String) -> Json<GenericResponse<'m>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[delete("/video?<id>")]
|
||||
pub fn delete_video(key: ApiKey, id: String) -> Json<GenericResponse<'m>> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
#[update("/name?<id>&<dest>")]
|
||||
pub fn update_vid_name<'m>(key: ApiKey, id: String, dest: String) -> Json<GenericResponse<'m>> {
|
||||
todo!()
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
use rocket_contrib::serve::StaticFiles;
|
||||
use std::env;
|
||||
|
||||
mod api;
|
||||
|
||||
#[get("/<id>")]
|
||||
fn video_page(id: u64) -> String {
|
||||
@ -14,7 +15,14 @@ fn main() {
|
||||
env::set_var("ROCKET_CLI_COLORS", "off");
|
||||
|
||||
let _ = rocket::ignite()
|
||||
.mount("/video", routes![video_page])
|
||||
.mount("/clip", routes![video_page])
|
||||
.mount("/video-api", routes![
|
||||
api::get_vid_by_id,
|
||||
api::get_vid_by_name,
|
||||
api::update_description,
|
||||
api::delete_video,
|
||||
api::update_vid_name,
|
||||
])
|
||||
.mount("/", StaticFiles::from("static"))
|
||||
.launch();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user