Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
Extend dummy api
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueDoctor committed Aug 3, 2020
1 parent 30b4c2a commit fbc09a1
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 7 deletions.
178 changes: 173 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions lobby/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ serde_derive = "1.0"
serde_json = "1.0"
diesel = { version = "1.4", features = ["postgres"] }
dotenv = "0.15.0"
rust-argon2 = "0.8"

[dependencies.rocket_contrib]
version = "0.4.4"
Expand Down
8 changes: 7 additions & 1 deletion lobby/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ pub mod db {
game_type_id: &'a i32,
}
}
use serde_derive::Serialize;
use rocket::request::FromForm;
use serde_derive::{Deserialize, Serialize};

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
Expand All @@ -50,6 +51,11 @@ pub struct GameType {
pub display_name: String,
}

#[derive(Debug, Serialize, Deserialize, FromForm)]
pub struct Password {
pub password: String,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct Game {
Expand Down
26 changes: 25 additions & 1 deletion lobby/src/routes.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use crate::models::{Game, GameOverview, GameType, TokenResponse};
use rocket::get;
use rocket::request::Form;
use rocket::{delete, get, post};
use rocket_contrib::json::Json;

// routes are here for now :)
Expand Down Expand Up @@ -32,6 +33,29 @@ pub fn game_index() -> Json<GameOverview> {

Json(mock_data)
}

#[get("/api/lobby/types", format = "json")]
pub fn get_types() -> Json<GameOverview> {
unimplemented!()
}

#[get("/api/lobby/groups/<id>", format = "json")]
pub fn get_group(id: u32) -> Json<GameOverview> {
unimplemented!()
}

use rocket::response::status::{Accepted, NotFound};

#[post("/api/lobby/groups/<id>", data = "<pw>", format = "json")]
pub fn create_group(id: u32, pw: Form<crate::models::Password>) -> &'static str {
"42"
}

#[delete("/api/lobby/groups/<id>", format = "json")]
pub fn delete_group(id: u32) -> Json<GameOverview> {
unimplemented!()
}

use std::time::{SystemTime, UNIX_EPOCH};

#[get("/api/lobby/tokens/<token>", format = "json")]
Expand Down

0 comments on commit fbc09a1

Please sign in to comment.