Skip to content

Commit ba27ae5

Browse files
authored
Serve a page on / for payjoin-directory (payjoin#824)
This commit addresses payjoin#818 .
2 parents 40e1035 + 3e34f45 commit ba27ae5

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

payjoin-directory/src/lib.rs

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ async fn serve_payjoin_directory(
185185
(Method::GET, ["", "ohttp-keys"]) => get_ohttp_keys(&ohttp).await,
186186
(Method::POST, ["", id]) => post_fallback_v1(id, query, body, pool).await,
187187
(Method::GET, ["", "health"]) => health_check().await,
188+
(Method::GET, ["", ""]) => handle_directory_home_path().await,
188189
_ => Ok(not_found()),
189190
}
190191
.unwrap_or_else(|e| e.to_response());
@@ -267,6 +268,67 @@ async fn health_check() -> Result<Response<BoxBody<Bytes, hyper::Error>>, Handle
267268
Ok(Response::new(empty()))
268269
}
269270

271+
async fn handle_directory_home_path() -> Result<Response<BoxBody<Bytes, hyper::Error>>, HandlerError>
272+
{
273+
let mut res = Response::new(empty());
274+
*res.status_mut() = StatusCode::OK;
275+
res.headers_mut().insert(CONTENT_TYPE, HeaderValue::from_static("text/html"));
276+
277+
let html = r#"
278+
<!DOCTYPE html>
279+
<html lang="en">
280+
<head>
281+
<meta charset="UTF-8">
282+
<title>Payjoin Directory</title>
283+
<style>
284+
body {
285+
background-color: #0f0f0f;
286+
color: #eaeaea;
287+
font-family: Manrope, sans-serif;
288+
padding: 2rem;
289+
display: flex;
290+
justify-content: center;
291+
align-items: center;
292+
height: 100vh;
293+
}
294+
.container {
295+
background: #1a1a1a;
296+
border: 1px solid #333;
297+
border-radius: 8px;
298+
padding: 2rem;
299+
box-shadow: 0 0 10px rgba(0, 170, 255, 0.2);
300+
text-align: center;
301+
}
302+
h1 {
303+
color: black;
304+
background-color: #C71585;
305+
margin-bottom: 1rem;
306+
padding: 0.5rem;
307+
border-radius: 4px;
308+
}
309+
p {
310+
color: #ccc;
311+
}
312+
a{
313+
color: #F75394;
314+
text-decoration: none;
315+
}
316+
</style>
317+
</head>
318+
<body>
319+
<div class="container">
320+
<h1>Payjoin Directory</h1>
321+
<p>The Payjoin Directory provides a rendezvous point for sender and receiver to meet. The directory stores Payjoin payloads to support asynchronous communication.</p>
322+
<p>Learn more about how asynchronous payjoin works here: <a href="https://payjoin.org/docs/how-it-works/payjoin-v2-bip-77">Payjoin V2</a></p>
323+
</div>
324+
</body>
325+
</html>
326+
"#;
327+
328+
*res.body_mut() = full(html);
329+
Ok(res)
330+
}
331+
270332
#[derive(Debug)]
271333
enum HandlerError {
272334
PayloadTooLarge,

0 commit comments

Comments
 (0)