add invitee name
This commit is contained in:
parent
bc85030ad3
commit
db689dcde7
13
src/main.rs
13
src/main.rs
|
@ -7,11 +7,12 @@ use warp::{http::StatusCode, reject::Rejection, reply::{html, json, with_status,
|
||||||
#[derive(Debug, Clone, Template)]
|
#[derive(Debug, Clone, Template)]
|
||||||
#[template(path = "invite.html")]
|
#[template(path = "invite.html")]
|
||||||
struct Invite {
|
struct Invite {
|
||||||
pub name: String
|
pub name: String,
|
||||||
|
pub invitee: String
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
|
async fn gen(name: String, invitee: String) -> Result<Box<dyn Reply>, Rejection> {
|
||||||
let inv = Invite { name };
|
let inv = Invite { name, invitee };
|
||||||
let rendered = inv.render();
|
let rendered = inv.render();
|
||||||
if let Err(err) = rendered {
|
if let Err(err) = rendered {
|
||||||
Ok(
|
Ok(
|
||||||
|
@ -26,6 +27,8 @@ async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let route = warp::path!("gen" / String).and_then(gen);
|
let route = warp::path!("gen" / String / String).and_then(gen);
|
||||||
warp::serve(route).bind(env::var("LISTEN").unwrap_or("0.0.0.0:80".into()).parse::<SocketAddrV4>().expect("Invalid LISTEN url")).await;
|
let url = env::var("LISTEN").unwrap_or("0.0.0.0:80".into()).parse::<SocketAddrV4>().expect("Invalid LISTEN url");
|
||||||
|
println!("Listening on {url}");
|
||||||
|
warp::serve(route).bind(url).await;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
<body>
|
<body>
|
||||||
<h1>you have been invited to join blek! cc!</h1>
|
<h1>you have been invited to join blek! cc!</h1>
|
||||||
<p>
|
<p>
|
||||||
a trusted member {{ name }} has invited you to join blek! cc
|
a trusted member {{ name }} has invited you ({{ invitee }}) to join blek! cc
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
if you want to create an account, please follow these instructions:
|
if you want to create an account, please follow these instructions:
|
||||||
|
|
Loading…
Reference in New Issue