Fresh Start
This commit is contained in:
59
main.rs
59
main.rs
@@ -1,59 +1,12 @@
|
||||
#![feature(plugin)]
|
||||
#![plugin(rocket_codegen)]
|
||||
#![feature(proc_macro_hygiene, decl_macro)]
|
||||
|
||||
use std::str::FromStr;
|
||||
|
||||
|
||||
|
||||
extern crate rocket;
|
||||
#[macro_use] extern crate rocket_contrib;
|
||||
use rocket::http::RawStr;
|
||||
use rocket_contrib::Json;
|
||||
|
||||
//extern crate serde_json;
|
||||
//use serde_json::{Value, Error};
|
||||
|
||||
extern crate rand;
|
||||
use rand::Rng;
|
||||
|
||||
extern crate base64;
|
||||
|
||||
fn main()
|
||||
{
|
||||
rocket::ignite().mount("/", routes![index,login,]).launch();
|
||||
}
|
||||
#[macro_use] extern crate rocket;
|
||||
|
||||
#[get("/")]
|
||||
fn index() -> &'static str {
|
||||
"Owo What's this\n
|
||||
You probably shouldn't be here! :D"
|
||||
"Hello, world!"
|
||||
}
|
||||
|
||||
#[get("/login/<username>/<password>")]
|
||||
fn login(username: &RawStr, password: &RawStr) -> Json
|
||||
{
|
||||
let mut rng = rand::thread_rng();
|
||||
let session: u64 = rng.gen();
|
||||
|
||||
let session = format!("{:x}", session);
|
||||
Json(json!(session))
|
||||
}
|
||||
|
||||
#[get("/game/<game_id>/<session_id>/get_stars")]
|
||||
fn get_stars(game_id: &RawStr, session_id: &RawStr) -> Json
|
||||
{
|
||||
let player = Player {
|
||||
name: "Daniel",
|
||||
color: (0,255,255)
|
||||
};
|
||||
|
||||
|
||||
let star = Star {
|
||||
id: 80085,
|
||||
name: "Loli sanctuary",
|
||||
coordinates: (50, 64),
|
||||
resources: 50
|
||||
};
|
||||
|
||||
Json(star)
|
||||
}
|
||||
fn main() {
|
||||
rocket::ignite().mount("/", routes![index]).launch();
|
||||
}
|
||||
Reference in New Issue
Block a user