pub struct HttpApi<H> { /* private fields */ }Expand description
HTTP API service builder.
§Also
ApiHandlerthe trait backing all endpoints.ApiErrormapped to JSON + HTTP status codes.
Implementations§
Source§impl<H> HttpApi<H>where
H: ApiHandler,
impl<H> HttpApi<H>where
H: ApiHandler,
Sourcepub fn with_auth(self, token: Token) -> Self
pub fn with_auth(self, token: Token) -> Self
Require a bearer token on every request.
When set, requests without a valid Authorization: Bearer <token> header are rejected with 401 Unauthorized before reaching any handler .
This is the same shared secret the agent presents to the control plane in discovery, one config value enables both directions.
Orthogonal to TLS. When unset, no auth is enforced.
Sourcepub fn router(self) -> Router
pub fn router(self) -> Router
Build axum router with mounted endpoints.
Applies a RequestBodyLimitLayer capped at MAX_REQUEST_BYTES bytes to every request,
and when with_auth is set a bearer-token gate that runs before any handler.
Auto Trait Implementations§
impl<H> Freeze for HttpApi<H>
impl<H> RefUnwindSafe for HttpApi<H>where
H: RefUnwindSafe,
impl<H> Send for HttpApi<H>
impl<H> Sync for HttpApi<H>
impl<H> Unpin for HttpApi<H>
impl<H> UnsafeUnpin for HttpApi<H>
impl<H> UnwindSafe for HttpApi<H>where
H: RefUnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request