Initial commit
This commit is contained in:
commit
4691022bfc
|
@ -0,0 +1 @@
|
|||
/target
|
File diff suppressed because it is too large
Load Diff
|
@ -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"
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
To build and run the project, do:
|
||||
|
||||
`cargo build`
|
||||
`cargo run`
|
||||
|
||||
To run tests:
|
||||
|
||||
`cargo test`
|
|
@ -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;
|
||||
}
|
Loading…
Reference in New Issue