Neo-Poseidon/Server/main.rs

51 lines
876 B
Rust

#![feature(plugin)]
#![plugin(rocket_codegen)]
use std::str::FromStr;
extern crate rocket;
extern crate rocket_contrib;
use rocket::http::RawStr;
use rocket_contrib::Json;
extern crate rand;
use rand::Rng;
extern crate base64;
fn main()
{
rocket::ignite().mount("/", routes![index,login]).launch();
}
#[get("/")]
fn index() -> &'static str {
"Owo What's this\n
You probably shouldn't be here! :D"
}
#[get("/login/<username>/<password>")]
fn login(username: &RawStr, password: &RawStr) -> String
{
let mut rng = rand::thread_rng();
let session: u64 = rng.gen();
format!("{:x}", session)
}
/*#[get("/<game_id>/<session_id>/get_stars")]
fn get_stars(game_id: &RawStr, session_id: &RawStr) -> Json
{
let data = r#"{[
{
id: 0,
"name": "StarGazer",
"resources": 43,
"coordinates {
x: 40,
y: 50
},
]}"#;
*/}