pub struct WebhookServer { /* private fields */ }
Expand description
A ready-to-use webhook server.
This server abstracts away lower-level details like TLS termination
and other various configurations, validations or middlewares. The routes
and their handlers are completely customizable by bringing your own
Axum [Router
].
For complete end-to-end implementations, see ConversionWebhookServer
.
Implementations§
Source§impl WebhookServer
impl WebhookServer
Sourcepub async fn new(
router: Router,
options: WebhookOptions,
) -> Result<(Self, Receiver<Certificate>)>
pub async fn new( router: Router, options: WebhookOptions, ) -> Result<(Self, Receiver<Certificate>)>
Creates a new ready-to-use webhook server.
The server listens on socket_addr
which is provided via the WebhookOptions
and handles
routing based on the provided Axum router
. Most of the time it is sufficient to use
WebhookOptions::default()
. See the documentation for WebhookOptions
for more details
on the default values.
To start the server, use the WebhookServer::run()
function. This will
run the server using the Tokio runtime until it is terminated.
§Basic Example
use stackable_webhook::{WebhookServer, WebhookOptions};
use axum::Router;
let router = Router::new();
let (server, cert_rx) = WebhookServer::new(router, WebhookOptions::default())
.await
.expect("failed to create WebhookServer");
§Example with Custom Options
use stackable_webhook::{WebhookServer, WebhookOptions};
use axum::Router;
let options = WebhookOptions::builder()
.bind_address([127, 0, 0, 1], 8080)
.add_subject_alterative_dns_name("my-san-entry")
.build();
let router = Router::new();
let (server, cert_rx) = WebhookServer::new(router, options)
.await
.expect("failed to create WebhookServer");
Auto Trait Implementations§
impl Freeze for WebhookServer
impl !RefUnwindSafe for WebhookServer
impl Send for WebhookServer
impl Sync for WebhookServer
impl Unpin for WebhookServer
impl !UnwindSafe for WebhookServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered
].