steid

@jamesgill /

Rust27.8 KBCode·Blame·History·Raw
1//! Webhooks — `/{handle}/repos/{name}/settings/hooks`.
2//!
3//! Owner-only, and 404 for anyone else, exactly as
4//! [`repo_settings`](super::repo_settings) is: a 403 would confirm that a private
5//! repository by that name exists.
6//!
7//! Two pages. The list is where a hook is added and removed, and where its most recent
8//! delivery is visible as a dot. The detail page is the delivery log — the thing anybody
9//! actually opens, because they are here to find out why their endpoint is not being
10//! called.
11
12use std::time::SystemTime;
13
14use serde::Deserialize;
15use topcoat::{
16 Result,
17 context::Cx,
18 icon::{icon, iconify::iconify_icon},
19 router::{StatusCode, content::Form, error::not_found, page, path_param, query_params},
20 view::{attributes, component, view},
21};
22
23use crate::{
24 application::{
25 Error, RepoView, WebhookDetail, WebhookSummary, create_webhook, delete_webhook,
26 list_webhooks, redeliver, set_webhook_active, view_webhook,
27 },
28 components::{
29 badge::{BadgeVariant, badge},
30 button::{ButtonSize, ButtonVariant, button},
31 flash::{FlashKind, flash},
32 input::input,
33 label::label,
34 },
35 domain::{DomainError, WebhookDelivery, WebhookDeliveryId, WebhookId, WebhookUrl},
36 infrastructure::clock::SystemClock,
37};
38
39use super::{
40 browse::timestamp,
41 context::{
42 current_actor, deliveries, location, memberships, orgs, private_targets, public_origin,
43 push_events, queries, repos, server_error, users, webhook_sender, webhooks,
44 },
45 layout::narrow,
46 paging::{Pages, list_pages, requested_page, showing},
47 repo::repo_for,
48};
49
50/// `{hook}` from the path — a webhook's id.
51#[path_param]
52struct Hook(str);
53
54/// `{delivery}` from the path — one recorded attempt's id.
55#[path_param]
56struct Delivery(str);
57
58#[derive(Debug, Deserialize)]
59struct AddForm {
60 url: String,
61}
62
63/// What a redirect back onto one of these pages has to say for itself.
64///
65/// Three separate flags rather than one `notice=…`: each is written by a different route
66/// and read by a different sentence, and collapsing them into one string would mean
67/// parsing it back apart.
68#[query_params(error = bad_request)]
69struct Notices {
70 removed: Option<String>,
71 /// `on` or `off`, after the toggle.
72 state: Option<String>,
73 /// `ok` or `failed`, after a redelivery.
74 sent: Option<String>,
75 /// `?page=N` on the deliveries list. It sits beside the notices rather than in a
76 /// struct of its own because a redirect back onto this page carries both.
77 page: Option<String>,
78}
79
80/// Which state a toggle is asking for.
81///
82/// The *wanted* state rather than "the other one", so a reload of the POST or a second
83/// click lands on the same answer instead of flipping back — see
84/// [`set_webhook_active`].
85#[derive(Debug, Deserialize)]
86struct ToggleForm {
87 active: String,
88 /// Present only when the form was submitted from the hook's own page, which is where
89 /// the redirect then goes back to.
90 detail: Option<String>,
91}
92
93/// The repository in the path, or 404 for anyone who does not own it.
94///
95/// The use cases decide this too; the guard here only keeps a page from rendering for
96/// someone whose submission would be refused anyway.
97async fn owned(cx: &Cx) -> Result<RepoView> {
98 let repo = repo_for(cx).await?;
99
100 if !repo.viewer_is_owner {
101 return Err(not_found().into());
102 }
103
104 Ok(repo)
105}
106
107/// Collapses a use case failure into what a page can do about it.
108///
109/// Validation is the visitor's to fix and is shown; everything else about ownership is
110/// the same 404 the guard above gives.
111fn explain(error: Error) -> Result<String> {
112 match error {
113 Error::Domain(DomainError::Validation { field, reason }) => {
114 Ok(format!("That {field} is no good: {reason}."))
115 }
116 Error::Domain(DomainError::Forbidden | DomainError::NotFound { .. }) => {
117 Err(not_found().into())
118 }
119 other => Err(server_error(std::io::Error::other(other.to_string()))),
120 }
121}
122
123async fn listing(cx: &Cx, repo: &RepoView) -> Result<Vec<WebhookSummary>> {
124 list_webhooks(
125 &current_actor(cx).await?,
126 &repo.handle,
127 &repo.name,
128 &orgs(cx),
129 &memberships(cx),
130 &repos(cx),
131 &webhooks(cx),
132 &deliveries(cx),
133 )
134 .await
135 .map_err(|error| match error {
136 // The guard above already answered this for the page; reaching it here means the
137 // repository went away between the two reads.
138 Error::Domain(DomainError::Forbidden | DomainError::NotFound { .. }) => not_found().into(),
139 other => server_error(std::io::Error::other(other.to_string())),
140 })
141}
142
143#[page("/{handle}/repos/{name}/settings/hooks")]
144async fn hooks_page(cx: &Cx) -> Result {
145 let repo = owned(cx).await?;
146 let listed = listing(cx, &repo).await?;
147 let notices = query_params::<Notices>(cx)?;
148
149 view! {
150 hooks_view(
151 handle: repo.handle.as_str(),
152 name: repo.name.as_str(),
153 hooks: &listed,
154 notice: Notice {
155 removed: notices.removed.is_some(),
156 state: notices.state.as_deref().unwrap_or_default(),
157 ..Notice::default()
158 },
159 )
160 }
161}
162
163/// Adds a hook and shows its secret, once.
164///
165/// **This deliberately does not redirect**, for the same reason issuing a token does not
166/// — see [`token::issue`](super::token). The secret exists only in this response, and
167/// surviving a redirect would mean putting it in a URL.
168#[page(POST "/{handle}/repos/{name}/settings/hooks")]
169async fn add(cx: &Cx, Form(submitted): Form<AddForm>) -> Result {
170 let repo = owned(cx).await?;
171
172 let outcome = create_webhook(
173 &current_actor(cx).await?,
174 &repo.handle,
175 &repo.name,
176 submitted.url.trim(),
177 SystemTime::now(),
178 private_targets(cx),
179 &orgs(cx),
180 &memberships(cx),
181 &repos(cx),
182 &webhooks(cx),
183 )
184 .await;
185
186 let (created, error) = match outcome {
187 Ok(created) => (created.secret.reveal().to_owned(), String::new()),
188 Err(error) => (String::new(), explain(error)?),
189 };
190
191 let listed = listing(cx, &repo).await?;
192
193 view! {
194 hooks_view(
195 handle: repo.handle.as_str(),
196 name: repo.name.as_str(),
197 hooks: &listed,
198 notice: Notice {
199 created: created.as_str(),
200 removed: false,
201 state: "",
202 error: error.as_str(),
203 // Cleared on success so the field is ready for the next one, kept on
204 // failure so a rejected URL is not silently thrown away.
205 url: if created.is_empty() { submitted.url.as_str() } else { "" },
206 },
207 )
208 }
209}
210
211/// Removes a hook, then redirects so a reload cannot repeat it.
212#[page(POST "/{handle}/repos/{name}/settings/hooks/{hook}/delete")]
213async fn remove(cx: &Cx) -> Result {
214 let repo = owned(cx).await?;
215 let id = WebhookId::from_trusted(path_param::<Hook>(cx));
216
217 match delete_webhook(
218 &current_actor(cx).await?,
219 &repo.handle,
220 &repo.name,
221 &id,
222 &orgs(cx),
223 &memberships(cx),
224 &repos(cx),
225 &webhooks(cx),
226 )
227 .await
228 {
229 Ok(()) => {}
230 // Already gone, or never this repository's. Both are "no such hook of yours",
231 // and both leave the list looking the way the visitor wanted it.
232 Err(Error::Domain(DomainError::NotFound { .. })) => {}
233 Err(other) => return Err(server_error(std::io::Error::other(other.to_string()))),
234 }
235
236 view! {
237 (StatusCode::SEE_OTHER)
238 (location(&format!(
239 "/{}/repos/{}/settings/hooks?removed",
240 repo.handle, repo.name
241 ))?)
242 }
243}
244
245/// Turns a hook on or off, from either page.
246///
247/// **One route for both.** The list and the detail page render the same button against
248/// the same hook, and a second route would be the same use case call with a different
249/// redirect — so the redirect is what the form says, through the presence of `detail`,
250/// rather than what the URL says.
251#[page(POST "/{handle}/repos/{name}/settings/hooks/{hook}/toggle")]
252async fn toggle(cx: &Cx, Form(submitted): Form<ToggleForm>) -> Result {
253 let repo = owned(cx).await?;
254 let id = WebhookId::from_trusted(path_param::<Hook>(cx));
255 let wanted = submitted.active == "true";
256
257 match set_webhook_active(
258 &current_actor(cx).await?,
259 &repo.handle,
260 &repo.name,
261 &id,
262 wanted,
263 &orgs(cx),
264 &memberships(cx),
265 &repos(cx),
266 &webhooks(cx),
267 )
268 .await
269 {
270 Ok(_) => {}
271 // Gone between the page rendering and the click. The list will show that.
272 Err(Error::Domain(DomainError::NotFound { .. })) => {}
273 Err(other) => return Err(server_error(std::io::Error::other(other.to_string()))),
274 }
275
276 let state = if wanted { "on" } else { "off" };
277
278 let back = match submitted.detail.is_some() {
279 true => format!(
280 "/{}/repos/{}/settings/hooks/{id}?state={state}",
281 repo.handle, repo.name
282 ),
283 false => format!(
284 "/{}/repos/{}/settings/hooks?state={state}",
285 repo.handle, repo.name
286 ),
287 };
288
289 view! {
290 (StatusCode::SEE_OTHER)
291 (location(&back)?)
292 }
293}
294
295/// Sends one recorded attempt's payload again.
296///
297/// **Awaited rather than spawned**, unlike a push's deliveries: somebody is looking at
298/// this page and the answer is the whole point of the button, so the request holds for
299/// as long as one attempt takes — at most the sender's ten-second timeout, and no retry
300/// schedule behind it. Spawning would redirect to a page that does not yet know what
301/// happened.
302#[page(POST "/{handle}/repos/{name}/settings/hooks/{hook}/deliveries/{delivery}/redeliver")]
303async fn resend(cx: &Cx) -> Result {
304 let repo = owned(cx).await?;
305 let hook = WebhookId::from_trusted(path_param::<Hook>(cx));
306 let delivery = WebhookDeliveryId::from_trusted(path_param::<Delivery>(cx));
307
308 let outcome = redeliver(
309 &current_actor(cx).await?,
310 &repo.handle,
311 &repo.name,
312 &hook,
313 &delivery,
314 &public_origin(cx),
315 &orgs(cx),
316 &memberships(cx),
317 &repos(cx),
318 &users(cx),
319 &webhooks(cx),
320 &deliveries(cx),
321 &push_events(cx),
322 &queries(cx),
323 &webhook_sender(cx),
324 &SystemClock,
325 )
326 .await;
327
328 let sent = match outcome {
329 Ok(delivery) if delivery.ok => "ok",
330 Ok(_) => "failed",
331 // An attempt or an event that is not there any more is not a page's problem: the
332 // log it redirects to is the answer either way.
333 Err(Error::Domain(DomainError::NotFound { .. })) => "failed",
334 Err(other) => return Err(server_error(std::io::Error::other(other.to_string()))),
335 };
336
337 view! {
338 (StatusCode::SEE_OTHER)
339 (location(&format!(
340 "/{}/repos/{}/settings/hooks/{hook}?sent={sent}",
341 repo.handle, repo.name
342 ))?)
343 }
344}
345
346#[page("/{handle}/repos/{name}/settings/hooks/{hook}")]
347async fn hook_page(cx: &Cx) -> Result {
348 let repo = owned(cx).await?;
349 let id = WebhookId::from_trusted(path_param::<Hook>(cx));
350
351 let detail = view_webhook(
352 &current_actor(cx).await?,
353 &repo.handle,
354 &repo.name,
355 &id,
356 requested_page(query_params::<Notices>(cx)?.page.as_deref()),
357 &orgs(cx),
358 &memberships(cx),
359 &repos(cx),
360 &webhooks(cx),
361 &deliveries(cx),
362 )
363 .await;
364
365 let detail = match detail {
366 Ok(detail) => detail,
367 // A hook id that is not this repository's is not a page.
368 Err(_) => return Err(not_found().into()),
369 };
370
371 let notices = query_params::<Notices>(cx)?;
372
373 view! {
374 hook_view(
375 handle: repo.handle.as_str(),
376 name: repo.name.as_str(),
377 hook: &detail,
378 state: notices.state.as_deref().unwrap_or_default(),
379 sent: notices.sent.as_deref().unwrap_or_default(),
380 )
381 }
382}
383
384/// The dot beside a hook, and its label.
385///
386/// Three states, because "never delivered" is not "failing": a hook added a minute ago
387/// has nothing wrong with it. Colour is the only place on these pages it carries
388/// meaning, so the dot is the one coloured thing in a row.
389fn status_of(last: Option<&WebhookDelivery>) -> (&'static str, String) {
390 match last {
391 Some(delivery) if delivery.ok => {
392 ("bg-success", format!("{} · ok", delivery.status_label()))
393 }
394 Some(delivery) => ("bg-destructive", delivery.status_label()),
395 None => ("bg-muted-foreground/40", "no deliveries yet".to_owned()),
396 }
397}
398
399/// What the page has to say about the last thing that happened, grouped so the view
400/// takes one argument for it rather than four that must stay in the same order at three
401/// call sites — the shape `repo_settings`'s `Fields` already uses.
402#[derive(Debug, Clone, Copy, Default)]
403struct Notice<'a> {
404 /// A secret to show exactly once. Empty otherwise.
405 created: &'a str,
406 removed: bool,
407 /// `on` or `off` after the toggle, empty otherwise.
408 state: &'a str,
409 error: &'a str,
410 /// What was typed, kept on a rejected submission.
411 url: &'a str,
412}
413
414/// The list of hooks, the add form, and the secret when one has just been made.
415#[component]
416async fn hooks_view(
417 handle: &str,
418 name: &str,
419 hooks: &[WebhookSummary],
420 notice: Notice<'_>,
421) -> Result {
422 let Notice {
423 created,
424 removed,
425 state,
426 error,
427 url,
428 } = notice;
429
430 view! {
431 narrow(
432 <h1 class="text-xl font-semibold tracking-tight">"Webhooks"</h1>
433 <p class="mt-1 font-mono text-sm text-muted-foreground">
434 "@" (handle) " / " (name)
435 </p>
436 <p class="mt-2 text-sm text-muted-foreground">
437 "Every push to this repository is POSTed to each hook as signed JSON, "
438 "once per ref that moved."
439 </p>
440
441 if !created.is_empty() {
442 <div class="mt-6 space-y-2">
443 flash(
444 kind: FlashKind::Success,
445 "Copy this secret now — it is not shown again."
446 )
447 <pre class="overflow-x-auto rounded-lg border border-border bg-surface px-4 py-3 font-mono text-sm">(created)</pre>
448 <p class="text-xs text-muted-foreground">
449 "Sent as "
450 <code class="font-mono">"X-Steid-Signature-256: sha256=<hex>"</code>
451 " — the HMAC-SHA-256 of the exact body, keyed with this."
452 </p>
453 </div>
454 }
455
456 if removed {
457 <div class="mt-6">
458 flash(kind: FlashKind::Success, "Webhook removed.")
459 </div>
460 }
461
462 if !state.is_empty() {
463 <div class="mt-6">
464 flash(
465 kind: FlashKind::Success,
466 (if state == "on" {
467 "Webhook turned on. The next push will be delivered."
468 } else {
469 "Webhook turned off. Its deliveries are kept."
470 })
471 )
472 </div>
473 }
474
475 if !error.is_empty() {
476 <div class="mt-6">
477 flash(kind: FlashKind::Error, (error))
478 </div>
479 }
480
481 <form
482 method="post"
483 action=(format!("/{handle}/repos/{name}/settings/hooks"))
484 class="mt-6 space-y-5"
485 >
486 <div class="space-y-2">
487 label(attrs: attributes! { for="url" }, "Payload URL")
488 input(attrs: attributes! {
489 id="url"
490 name="url"
491 type="text"
492 value=(url)
493 placeholder="https://example.com/steid-hook"
494 required=(true)
495 autocomplete="off"
496 maxlength=(WebhookUrl::MAX_LEN.to_string())
497 })
498 <p class="text-xs text-muted-foreground">
499 "Must be reachable from the internet. An address on this machine "
500 "or its private network is refused."
501 </p>
502 </div>
503
504 button(attrs: attributes! { type="submit" }, "Add webhook")
505 </form>
506
507 <section class="mt-10">
508 <h2 class="text-xs font-medium uppercase tracking-wider text-muted-foreground">
509 "Hooks"
510 </h2>
511
512 if hooks.is_empty() {
513 <p class="mt-2 rounded-lg border border-border px-4 py-6 text-center text-sm text-muted-foreground">
514 "No webhooks yet."
515 </p>
516 } else {
517 <ul class="mt-2 divide-y divide-border rounded-lg border border-border">
518 for hook in hooks {
519 <li class="flex items-center gap-3 px-4 py-3">
520 <span
521 class=(format!("size-2 shrink-0 rounded-full {}", status_of(hook.last.as_ref()).0))
522 title=(status_of(hook.last.as_ref()).1)
523 ></span>
524 <a
525 href=(format!("/{handle}/repos/{name}/settings/hooks/{}", hook.id))
526 class="min-w-0 flex-1 truncate font-mono text-sm hover:underline"
527 >(hook.url.as_str())</a>
528 if !hook.active {
529 badge(variant: BadgeVariant::Outline, "Off")
530 }
531 <span class="hidden shrink-0 font-mono text-xs text-muted-foreground sm:inline">
532 (status_of(hook.last.as_ref()).1)
533 </span>
534 // The wanted state, not "the other one": a reload of the
535 // POST then lands on the same answer rather than
536 // flipping the hook back.
537 <form
538 method="post"
539 action=(format!(
540 "/{handle}/repos/{name}/settings/hooks/{}/toggle",
541 hook.id
542 ))
543 class="shrink-0"
544 >
545 <input
546 type="hidden"
547 name="active"
548 value=(if hook.active { "false" } else { "true" })
549 />
550 button(
551 attrs: attributes! { type="submit" },
552 variant: ButtonVariant::Ghost,
553 size: ButtonSize::Sm,
554 (if hook.active { "Turn off" } else { "Turn on" })
555 )
556 </form>
557 <form
558 method="post"
559 action=(format!(
560 "/{handle}/repos/{name}/settings/hooks/{}/delete",
561 hook.id
562 ))
563 class="shrink-0"
564 >
565 // Ghost and small: the dot is the only coloured
566 // thing in a row, and a filled destructive button
567 // per hook would make the list read as a warning.
568 button(
569 attrs: attributes! { type="submit" },
570 variant: ButtonVariant::Ghost,
571 size: ButtonSize::Sm,
572 "Delete"
573 )
574 </form>
575 </li>
576 }
577 </ul>
578 }
579 </section>
580
581 <p class="mt-8">
582 <a
583 href=(format!("/{handle}/repos/{name}/settings"))
584 class="text-sm text-muted-foreground hover:text-foreground"
585 >"Back to repository settings"</a>
586 </p>
587 )
588 }
589}
590
591/// One hook and its recent attempts.
592#[component]
593async fn hook_view(
594 handle: &str,
595 name: &str,
596 hook: &WebhookDetail,
597 /// `on` or `off` after the toggle, empty otherwise.
598 state: &str,
599 /// `ok` or `failed` after a redelivery, empty otherwise.
600 sent: &str,
601) -> Result {
602 let deliveries = &hook.deliveries;
603 let sentence = showing(
604 deliveries.offset(),
605 deliveries.items.len(),
606 deliveries.total,
607 "attempts",
608 );
609 let pages = Pages::numbered(deliveries.page, deliveries.pages, |page| {
610 format!(
611 "/{handle}/repos/{name}/settings/hooks/{}?page={page}",
612 hook.id
613 )
614 });
615
616 view! {
617 narrow(
618 <div class="flex items-start justify-between gap-4">
619 <div class="min-w-0">
620 <h1 class="text-xl font-semibold tracking-tight">"Webhook"</h1>
621 <p class="mt-1 break-all font-mono text-sm text-muted-foreground">
622 (hook.url.as_str())
623 </p>
624 <p class="mt-1 text-xs text-muted-foreground">
625 "Added " (timestamp(hook.created_at))
626 if !hook.active { " · not active" }
627 </p>
628 </div>
629
630 // `detail` is what sends the redirect back here rather than to the list.
631 <form
632 method="post"
633 action=(format!("/{handle}/repos/{name}/settings/hooks/{}/toggle", hook.id))
634 class="shrink-0"
635 >
636 <input
637 type="hidden"
638 name="active"
639 value=(if hook.active { "false" } else { "true" })
640 />
641 <input type="hidden" name="detail" value="1" />
642 button(
643 attrs: attributes! { type="submit" },
644 variant: ButtonVariant::Outline,
645 size: ButtonSize::Sm,
646 (if hook.active { "Turn off" } else { "Turn on" })
647 )
648 </form>
649 </div>
650
651 if !state.is_empty() {
652 <div class="mt-4">
653 flash(
654 kind: FlashKind::Success,
655 (if state == "on" {
656 "Webhook turned on. The next push will be delivered."
657 } else {
658 "Webhook turned off. Its deliveries are kept."
659 })
660 )
661 </div>
662 }
663
664 if !sent.is_empty() {
665 <div class="mt-4">
666 if sent == "ok" {
667 flash(kind: FlashKind::Success, "Redelivered — the endpoint accepted it.")
668 } else {
669 flash(
670 kind: FlashKind::Error,
671 "Redelivery failed. The newest attempt below says what came back."
672 )
673 }
674 </div>
675 }
676
677 <section class="mt-6">
678 <div class="flex items-baseline justify-between gap-4">
679 <h2 class="text-xs font-medium uppercase tracking-wider text-muted-foreground">
680 "Deliveries"
681 </h2>
682 </div>
683
684 if hook.deliveries.items.is_empty() {
685 <p class="mt-2 rounded-lg border border-border px-4 py-6 text-center text-sm text-muted-foreground">
686 "Nothing has been delivered yet. Push to this repository to try it."
687 </p>
688 } else {
689 <ul class="mt-2 divide-y divide-border rounded-lg border border-border">
690 for delivery in &hook.deliveries.items {
691 delivery_row(
692 handle: handle,
693 name: name,
694 hook: &hook.id,
695 delivery: delivery,
696 )
697 }
698 </ul>
699 list_pages(summary: sentence.as_str(), pages: &pages)
700 }
701 </section>
702
703 <p class="mt-8">
704 <a
705 href=(format!("/{handle}/repos/{name}/settings/hooks"))
706 class="text-sm text-muted-foreground hover:text-foreground"
707 >"Back to webhooks"</a>
708 </p>
709 )
710 }
711}
712
713/// One attempt: when, which try, what came back, and how long it took.
714///
715/// The response is a `<details>` rather than a column — most of them are empty, and the
716/// one that is not is the whole reason somebody opened this page.
717#[component]
718async fn delivery_row(
719 handle: &str,
720 name: &str,
721 hook: &WebhookId,
722 delivery: &WebhookDelivery,
723) -> Result {
724 let (dot, _) = status_of(Some(delivery));
725
726 view! {
727 <li class="px-4 py-2.5">
728 <div class="flex items-center gap-3 text-xs">
729 <span class=(format!("size-2 shrink-0 rounded-full {dot}"))></span>
730 <span class="font-mono text-muted-foreground">
731 (timestamp(delivery.delivered_at))
732 </span>
733 <span class="font-mono">(delivery.status_label())</span>
734 <span class="ml-auto shrink-0 font-mono text-muted-foreground">
735 "try " (delivery.attempt.to_string())
736 " · " (delivery.duration_ms.to_string()) "ms"
737 </span>
738 // Ghost and small, like Delete on the list: the dot is the only coloured
739 // thing in a row, and every row carrying a filled button would make the
740 // log read as a list of problems.
741 <form
742 method="post"
743 action=(format!(
744 "/{handle}/repos/{name}/settings/hooks/{hook}/deliveries/{}/redeliver",
745 delivery.id
746 ))
747 class="shrink-0"
748 >
749 button(
750 attrs: attributes! { type="submit" },
751 variant: ButtonVariant::Ghost,
752 size: ButtonSize::Sm,
753 "Redeliver"
754 )
755 </form>
756 </div>
757
758 if !delivery.response.is_empty() {
759 <details class="mt-1.5">
760 <summary class="inline-flex cursor-pointer items-center gap-1 text-xs text-muted-foreground hover:text-foreground">
761 icon(data: iconify_icon!("feather:chevron-right"), attrs: attributes! {
762 class="size-3.5"
763 })
764 "Response"
765 </summary>
766 <pre class="mt-1.5 max-h-48 overflow-auto rounded-md border border-border bg-surface px-3 py-2 font-mono text-xs whitespace-pre-wrap">(delivery.response.as_str())</pre>
767 </details>
768 }
769 </li>
770 }
771}