Skip to content

Commit 8b518a0

Browse files
committed
Add some docs
1 parent 587f296 commit 8b518a0

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

crates/stackable-webhook/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,12 @@ impl WebhookServer {
7272
pub const DEFAULT_SOCKET_ADDRESS: SocketAddr =
7373
SocketAddr::new(Self::DEFAULT_LISTEN_ADDRESS, Self::DEFAULT_HTTPS_PORT);
7474

75+
/// Creates a new webhook server with the given config and list of webhooks.
76+
///
77+
/// Currently the webhooks [`ConversionWebhook`](servers::ConversionWebhook) and
78+
/// [`MutatingWebhook`](servers::MutatingWebhook) are implemented.
79+
///
80+
/// Please read their documentation for details.
7581
pub async fn new(
7682
options: WebhookServerOptions,
7783
webhooks: Vec<Box<dyn Webhook>>,

crates/stackable-webhook/src/servers/mod.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ pub enum WebhookError {
2424
},
2525
}
2626

27+
/// A webhook (such as a conversion or mutating webhook) needs to implement this trait.
28+
//
2729
// We still need to use the async-trait crate, as Rust 1.91.1 does not support dynamic dispatch
2830
// in combination with async functions.
2931
#[async_trait]
3032
pub trait Webhook {
33+
/// The webhook can add arbitrary routes to the passed [`Router`] and needs to return the
34+
/// resulting [`Router`].
3135
fn register_routes(&self, router: Router) -> Router;
3236

37+
/// The HTTPS server periodically rotates it's certificate.
38+
///
39+
/// Typically, some caller of the webhook (e.g. Kubernetes) needs to know the certificate to be
40+
/// able to establish the TLS connection.
41+
/// Webhooks are informed about new certificates by this function and can react accordingly.
3342
async fn handle_certificate_rotation(
3443
&mut self,
3544
new_certificate: &Certificate,

crates/stackable-webhook/src/servers/mutating_webhook.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub enum MutatingWebhookError {
3333
/// on the fly.
3434
///
3535
/// As the webhook is typed with the Resource type `R`, it can only handle a single resource
36-
/// mutation. Use multiple [`MutatingWebhookServer`] if you need to mutate multiple resource kinds.
36+
/// mutation. Use multiple [`MutatingWebhook`] if you need to mutate multiple resource kinds.
3737
///
3838
/// ### Example usage
3939
///

0 commit comments

Comments
 (0)