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)]
|
||||
#[template(path = "invite.html")]
|
||||
struct Invite {
|
||||
pub name: String
|
||||
pub name: String,
|
||||
pub invitee: String
|
||||
}
|
||||
|
||||
async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
|
||||
let inv = Invite { name };
|
||||
async fn gen(name: String, invitee: String) -> Result<Box<dyn Reply>, Rejection> {
|
||||
let inv = Invite { name, invitee };
|
||||
let rendered = inv.render();
|
||||
if let Err(err) = rendered {
|
||||
Ok(
|
||||
|
@ -26,6 +27,8 @@ async fn gen(name: String) -> Result<Box<dyn Reply>, Rejection> {
|
|||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let route = warp::path!("gen" / 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 route = warp::path!("gen" / String / String).and_then(gen);
|
||||
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>
|
||||
<h1>you have been invited to join blek! cc!</h1>
|
||||
<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>
|
||||
if you want to create an account, please follow these instructions:
|
||||
|
|
Loading…
Reference in New Issue