Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Unimplemented routes
- Loading branch information
1 parent
f560b4e
commit 156f6329dc75c13d6bc30d9be76600eeedede59a
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#![feature(decl_macro)] | ||
|
||
#[macro_use] | ||
extern crate rocket; | ||
|
||
use rocket_contrib::json::Json; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Deserialize, Serialize, Clone)] | ||
struct User { | ||
username: String, | ||
favorite_food: String, | ||
} | ||
|
||
type EndpointResult<T> = Result<T, &'static str>; | ||
|
||
#[get("/users/<username>")] | ||
fn get_user(username: String) -> EndpointResult<Json<User>> { | ||
todo!() | ||
} | ||
|
||
#[delete("/users/<username>")] | ||
fn delete_user(username: String) -> EndpointResult<Json<User>> { | ||
todo!() | ||
} | ||
|
||
#[put("/users", data = "<user>")] | ||
fn put_user(user: Json<User>) -> EndpointResult<Json<User>> { | ||
todo!() | ||
} | ||
|
||
fn main() { | ||
rocket::ignite() | ||
.mount("/api/", routes![get_user, put_user, delete_user]) | ||
.launch(); | ||
} |