Initial commit

This commit is contained in:
Niels Andriesse 2021-03-05 15:13:31 +11:00
commit 4691022bfc
5 changed files with 1159 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1113
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

13
Cargo.toml Normal file
View File

@ -0,0 +1,13 @@
[package]
name = "session-open-group-server"
version = "1.0.0"
authors = ["Niels Andriesse <andriesseniels@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
warp = "0.3"

9
README.md Normal file
View File

@ -0,0 +1,9 @@
To build and run the project, do:
`cargo build`
`cargo run`
To run tests:
`cargo test`

23
src/main.rs Normal file
View File

@ -0,0 +1,23 @@
use serde::{Deserialize, Serialize};
use warp::Filter;
#[derive(Deserialize, Serialize)]
struct Message {
text: String
}
#[tokio::main]
async fn main() {
// POST /messages
let send_message = warp::post()
.and(warp::path("messages"))
// Only accept bodies smaller than 256 kb
.and(warp::body::content_length_limit(1024 * 256))
.and(warp::body::json())
.map(|message: Message| {
warp::reply::json(&message)
});
warp::serve(send_message).run(([127, 0, 0, 1], 3030)).await;
}